There may be several webmasters who host their sites / blogs using either a VPS or dedicated hosting. With such kind of a setup you may not only get better performance, but may also have to deal with several headaches of maintaining the servers yourself.
Traffic spikes to your websites can send the Apache server into a frenzy locking down system resources. In such cases webmasters simply reboot their servers to overcome this issue, but there is a much more easier and graceful (at least better than reboot) way to recover system resources by using a simple tip.
If you can SSH into your server, you can easily recover from the traffic spikes without having to reboot the server. To do that follow the simple steps listed below.
- SSH into your server.
- Change privileges to root user, usually accomplished by issuing the command sudo su (not required if you issue commands using sudo command)
- Issue the command killall 9 apache2, the process name apache2 could be something different for your server, so use that name there.
- Issue the command /etc/init.d/apache2 startagain adjust the command to use the process name for apache on your server.
These four steps can save you the hassle of having to reboot every time you get traffic spikes, at times though gaining remote access to a server may not be possible and you may have to reboot the servers, but when you do have SSH access follow the steps listed above to do a (un)graceful restart of apache.
I am in the process of writing a shell script that will automatically restart apache, once it crosses a memory threshold, will share the script once its completed.
User Feedback: Are we not covering the topics you like? Are we writing something you don’t like? Do give us you feedback by using the contact us form, we will definitely try to improve on our shortcomings.