How do big sites like Stackoverflow, change styles and other files without interruption?

89 views Asked by At

I noticed yesterday that there was a new navigation bar on top of this site. And it has also added more features on the nav bar that definately requires server side changes or at least newer queries.

Yes it has ver attached to the css as a variable so that a fresh copy is loaded each visit. I want to know how do they complete the changes i.e. swapping of files without any downtime?

Perhaps there are loads of other things that go on in the back any insight would be good. Thanks.

2

There are 2 answers

0
Ria Weyprecht On

Well nobody knows how they really do it but what we do:

Use a staging server where your whole website is duplicated. Make all your changes there without nobody knowing what's happening as the website is provided by another server. And then just change your domain configuration so that the staging server becomes the new webserver and the other way arround.

2
holgac On

Although I don't think this question belongs in StackOverflow, I have some experience about changing a running website.

We had 3 different servers: Development, Stage, Production. We did all the development in development server. Then when we decided to migrate, we copied public_html folder with a different name to the same folder that current public_html resides in. Then we would swap names of the folders and, voila. We had a script that did that automatically: Pull from git, swap names.

We tested the script on stage server and if it didn't fail, we applied the same to the production server.

You can also change apache config to look for your new folder. Think of it as 'double buffering', old site is a buffer. The new site is loaded into a new buffer, then apache configuration is changed so that the new folder is used, ie. the buffers are swapped.

Swapping names is no big deal and I didn't experience any bad side effects to this method. But I guess changing apache config is a better idea.