Apache on VPS servers
A reminder to myself and a warning to others...
Had a problem recently with a new VPS server. It was a fairly standard, entry level affair, using Parallels and Plesk. It was serving a Drupal site, though hardly a very high traffic one. Yet it was regularly failing - the Apache processes would just get killed, quite often along with the monitoring program I installed to try to figure out what was happening (monit), and sometimes the Plesk control panel services.
I spoke to the ISP who said they, like me, could see nothing in the logs to indicate a problem. They recommended rebuilding the VPS and reinstalling all the sites. I wasn't really prepared to do this in case it was a feature of the sites, or the build they had used originally, that was causing the problem.
After some more investigation, it turned out that the Parallels Virtuozzo container running the VPS was causing the problem. What appeared to be happening was that Apache, with its stock config, was understandably using as much memory as it thought it could get away with in the interests of serving the site as quickly as possible. The container however, was seeing this as persistent and excessive use of burstable RAM, leading to occassional out of memory situations. When this happened, the container would seem to be simply killing processes within the VPS to bring the memory usage down. The big problem here was that nothing except a SIGTERM was logged in the VPS - no OOM warnings for instance, that would have indicated the problem far more quickly. There were some resource usage warnings in the Parallels control panel, but they were fairly vague and did not indicate that any process killing was taking place.
The solution was to adjust the configs for MySQL and Apache so they used less memory. In the case of Apache, this mainly involved reducing the number and lifetime of child processes. Problem solved.
Whether the ISP was overselling their hardware, or had just configured the memory limits badly I don't know, but the problem has not recurred.
- matt's blog
- Log in to post comments