Graceful restart of Apache Server - No downtime, Happy Clients

Graceful Restart Apache

I have been using webfaction for so many years and it is definitely one of the best shared hosting service I have ever used but since last year I felt the need to host sites on a VPS, there are certain things that you can only do when you have full control of the server. The problem with shared hosting is that you can't just do everything (but in most cases they are good enough). Also they RAM they offer is not enough sometimes.

Also our tech savvy clients want to use VPS and good that they are willing to pay for it too :) so that's why we started using VPS last year. When I researched about VPS hosting I narrowed down linode, it is not only affordable but also there support is good, they also have lot of online guides.

Apart from client websites we also use couple of linode machines for hosting our JIRA instance and our internal projects.

Earlier I used Ubuntu which is the most common choice of people but my lack of experience on Ubuntu and my personal love for Fedora and Cent OS forced me to select Cent OS. Also good thing about linode is that they upgrade your machines from time to time. Just recently they upgraded the RAM to 2GB on their basic plan. It is awesome now, especially our JIRA instance is running smooth without downtime.

Managing VPS is not for everyone. I have years of experience working on linux but when it comes to managing a server that will host your client's site, you just can't do thing you usually do on your linux machine locally. For instance you have to manage the memory, make sure there are no unnecessary processes running and you should be able to look into log files.

Most importantly you just can't afford to have downtimes. Clients don't like it and asking them for a downtime is embarrassing for us too.

I am not really an expert on managing Apache but this what I use for reloading the apache on cent OS. Apache needs to be reloaded whenever you do any changes in the httpd.conf or your vhost.conf files or you add a new site.

This command will apply the configuration changes.

  1. /etc/init.d/httpd reload

You can also do.

  1. /etc/init.d/httpd graceful

Both reload and graceful will apply the changes in the configuration without terminating / interrupting any connections. Simple the Apache will first process the request, complete it and then restart, so server will eventually restart but users should not see downtime. Well so far it serves our purpose but there could be a better way.

In any case this is better than full restart, ever since I moved to VPS, we have more power but more tensions too :) though it is good that we learn new things. Hopefully one day when our company Sparxsys grows we will hire an experience server administrator, till then I will have to learn more and manage the servers myself. Why not? An additional role for me.

That is the challenge and fun working in a startup, you wear multiple hats and manage tons of different things.

The problem with this command is that it will immediately terminate all the request currently handled by Apache.

Similar posts

Ravi Sagar Newsletter

Honestly I hardly send out mails but I guess there is no harm in at least having a newsletter. I will only send newsletter when I have something important to share or an update. People are busy and no one has time to read emails these days. If you really like my content then I guess you will remember my site and come back for more.

Want to contact me?