2

We are shortly moving to new server infrastructure which will have 2 webservers behind a load balancer that are deployed using Capistrano. The only area of concern I have is how to handle module updates (especially ones that modify the database using setup scripts).

If the two servers are hit at the same time the update scripts will trigger at the same time before sore_resource has been updated potentially causing Magento to crash.

I'm considering setting up an admin site on one server (separate copy of the codebase with it's own vhost) that is deployed to first and an update_modules script run to carry out the modifications of the DB and then deploying out to the live webservers.

Can anyone see any issues with this or have any other suggestions as to the best way to handle DB updates?

1

This is a basic task in general deployment strategy here that you need to add as step to your deployment pipeline.

If you worry that both codebases will execute the same setup tasks against same data storage then the only reasonable way is to ensure that this does not happen. I assume that you have already implemented "maintenance mode" for your site so i suggest you to add this if you have not done it jet and change your deployment pipeline:

Maintenance mode here is a status when your code is not online for public access and is only accessible for your deployment involved hosts. You can deploy code that does not execute database changes more freely without worrying about the order of execution.

  • maintenance mode on
  • whatever steps you have here , cache cleaning etc
  • code deploy to all hosts
  • tests to verify the deployment status
  • wget call to your main host to execute all setup tasks
  • tests to verify the success of those methods
  • whatever steps you have here , cache cleaning etc
  • maintenance mode off
  • Thanks Anton, Yes, I've thought about maintenance mode but ideally I don't want to have website downtime when I'm deploying (unless it's a full Magento upgrade etc of course). – Richard Cleverley Aug 9 '13 at 13:21
  • dependent of the update nature (how long it takes to run the setup scripts against your dataset) you need to take Magento offline sometimes , it's inevitable cause your setup scripts can turn in to situation where the "old code" will give you errors or false datasets. – Anton S Aug 9 '13 at 14:38
  • Oh yes, absolutely Anton, Upgrades etc always have to be done offline but small extension installs etc should be able to be done without going into maintenance mode. It can be very difficult to justify downtime on high volume sites. Probably go for an admin site that does the db upgrades as I've worked like that before. – Richard Cleverley Aug 9 '13 at 16:18
  • if you do it like this you can never be sure if after setup script run the front-ends won't break. – Anton S Aug 12 '13 at 7:11
  • You can by making sure new and upgraded extensions have been properly tested in test and staging environments. If an extension is going to break Magento due to schema changes then it should really be looked at carefully to see if it has been written in a safe and secure way. Some extensions will need maintenance mode (as will upgrades etc) but in normal operation modules should be able to be deployed and rolled back with out destroying the DB. – Richard Cleverley Aug 12 '13 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.