Solutions for "Maintenance Mode"

Posted by Ka Lyse on Programmers See other posts from Programmers or by Ka Lyse
Published on 2012-11-17T15:08:45Z Indexed on 2012/11/17 17:21 UTC
Read the original article Hit count: 202

Filed under:

Given a web application running across 10+ servers, what techniques have you put in place for doing things like altering the state of your website so that you can implement certain features.

For instance, you might want to:

  • Restrict Logins/Disable Certain Features
  • Turn Site to "Read Only"
  • Turn Site to Single "Maintenance Mode" page.

Doing any of the above is pretty trivial. You can throw a particular "flag" in an .ini file, or add a row/value to a site_options table in your database and just read that value and do the appropriate thing.

But these solutions have their problems.

Disadvantages/Problems

For instance, if you use a file for your application, and you want to switch off a certain feature temporarily, then you need to update this file on all servers. So then you might want to look at running something like ZooKeeper, but you are probably overcomplicating things.

So then, you might decide that you want to store these "feature" flags in a database. But then you are obviously adding unncessary queries to each page request. So you think to yourself, that you will throw memcached in to the mix and just cache the query. Then you just retrieve all of your "Features" from memcached and add a 2ms~ latency to your application on every page. So to get around this, you decide to use a two tier-cache system, whereby you use an inmemory cache on each machine, (like Apc/Redis etc). This would work, but then it gets complicated, because you would have to set the key/hash life to perhaps 60 seconds, so that when you purge/invalidate the memcached object storing your "Features" result, your on machine cache is prompt enough to get the the new states.

What suggestions might you have? Keeping in mind that optimization/efficiency is the priority here.

© Programmers or respective owner

Related posts about memcached