How to update frontend servers behind a load balancer I have multiple frontend servers churning out the HTML pages , behind a load balancer.

Just wondering what is the best practice to update the frontend app while users are surfing the site.

The objectives:


ensure each user see either the new or old version, but not flip between both. 
ensure load is still evenly distributed amongst servers that are not being updated.
no disruption to service.


My thoughts:


Divide the servers into groups. 
Take out a group from load balancing and wait for it to finish off current requests. 
Update the app and OS, etc.
put the group back to load balancing. 
Pick another group and repeat steps 2-5.


While in process, some servers will have the new version, so to ensure users do not flip between the old and new ones, do I enable sticky session?
What you have above seems like a reasonable update procedure, however you can also use persistence or a sticky session so that when a user goes to a web server, they will be routed to the same web server for the life of their browser session (or for the next hour, or whatever you decide to configure). This also allows for some A/B testing if you need to get user feedback on a new feature or just allow for the possibility of a bug (just pull server group B from the pool if an issue is discovered during A/B testing with that group).

There are some concerns you should be aware of with sticky sessions: Eg, source address persistence can be problematic if you have a thousand users behind a firewall - then you have a huge group that always goes to a single web node. Maybe you really don't want a cookie to do persistence, etc.

But, there really is no agreed "best practice" on this - the best practice is going to the the one that meets your business need in this case. You should just collect all of your options and choose the workflow that best meets your needs.