Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a pretty popular blog running on Wordpress. It uses PHP4 and MySQL 5.0 DB. Once in a while it happens that the MySQL server makes the server run really slow. The website does not work at that time (Wordpress cannot connect to the DB) and all the operations (even an SSH login) take 10 times longer than usually. Restarting MySQL does not help. I need to kill it (killall -9 mysqld) and start it again. Then it just starts working perfectly like before.
I'm sure it's some kind of configuration issue. The server is running Debian Etch and it's a PIII with 512MB RAM.
Do you have any ideas what the problem might be and how to solve it? If you need any logs, let me know and I'll use pastebin. I'm just not exactly sure where to look for.
Maybe apache is waiting for the database connections and growing beyond your available RAM?
Try working out how much traffic you server at peak times (number of connections and size of threads) and configure your web server and database tightly to that.
Maybe apache is waiting for the database connections and growing beyond your available RAM?
Try working out how much traffic you server at peak times (number of connections and size of threads) and configure your web server and database tightly to that.
That should help stop the server overloading.
I'm not an Apache expert by no means... so.. could you give me some clues which options I should tinker with? I'm getting some 1000-1500 hits an hour.
I can be a difficult thing to give specific advice on, as it depends on various things. The basic calculation is that if you have 128Mb of RAM and each Apache process uses, on average, 10Mb - then you should never have more than 12 at any one time (13 processes would be > 128Mb). Obviously these figures can vary greatly.
The only time I have experienced something similar to what you are describing is because Apache is creating more processes than the box can handle. The processes don't start off using up the full 10Mb (from the example above) and so end up in a deadlcok each process waiting for the other to release memory before it finishes it's job.
Reading up on MySQL configuration on their website could also be helpful (so that it fits well your Apache config).
Many other things can help with this problem (tune your SQL queries, tune your HTML, add RAM).
Maybe you are suffering from some other problem - but tuning your webserver config can never be bad
I can be a difficult thing to give specific advice on, as it depends on various things. The basic calculation is that if you have 128Mb of RAM and each Apache process uses, on average, 10Mb - then you should never have more than 12 at any one time (13 processes would be > 128Mb). Obviously these figures can vary greatly.
The only time I have experienced something similar to what you are describing is because Apache is creating more processes than the box can handle. The processes don't start off using up the full 10Mb (from the example above) and so end up in a deadlcok each process waiting for the other to release memory before it finishes it's job.
Reading up on MySQL configuration on their website could also be helpful (so that it fits well your Apache config).
Many other things can help with this problem (tune your SQL queries, tune your HTML, add RAM).
Maybe you are suffering from some other problem - but tuning your webserver config can never be bad
I moved the MySQL server to another machine and it seems that it was not MySQL killing the server but rather Apache killing MySQL. I just experienced a similar problem on the server with Apache only -- some cached pages still show up but all those that require a DB connection display a message about DB problems. But MySQL on the other server was up and running and I could connect to it w/o problems locally. Killing apache and restarting it was the only solution to bring life back into the server.
The machine is a PIII with 512MB of RAM.
Here are some apache settings that might be important to tweak:
As per my previous post, I'd recommend that you read up on Apache documentation (httpd.apache.org). Unless I missed it, you haven't stated which version you are using.
Your settings depend on what you are serving, to how many people and when.
Here is a setting for commercial web server that primarily delivers dynamic mod_perl content, where each process tends to be 35 to 40 Mb (10Mb shared) with 1Gb RAM:
To get a rudimentary idea of how big your processes are, log in to your sever when it is busy (or deliberately stress test it yourself) and type:
Code:
top | grep http
Read up on MaStartServers, MinSpareServers, MaxSpareServers, ServerLimit, MaxClients, MaxRequestsPerChild and understand how Apache controls it's threads. Monitor your usage and do some simple mathematics (size of process * number of processes = how much memory I have). That should give you some good starting values.
Read up on MaStartServers, MinSpareServers, MaxSpareServers, ServerLimit, MaxClients, MaxRequestsPerChild and understand how Apache controls it's threads. Monitor your usage and do some simple mathematics (size of process * number of processes = how much memory I have). That should give you some good starting values.
Thanks a lot for these hints. I'll let you all know if I had any success...
hi everyone,
I seem to be facing the same issue, it seems like instead of reusing the old unused apache2 processes. They just get bloated and apache spawns new processes to deal with new requests,it is a real killer on preformance. The only reason i can think of is that the processes are not either being recycled or killed
i apologise if im being abstract but im quite new to apache. Any progress being made as i am stumped.
hi everyone,
I seem to be facing the same issue, it seems like instead of reusing the old unused apache2 processes. They just get bloated and apache spawns new processes to deal with new requests,it is a real killer on preformance. The only reason i can think of is that the processes are not either being recycled or killed
i apologise if im being abstract but im quite new to apache. Any progress being made as i am stumped.
I fixed the issue finally by using phpaccellerator software. Well, perhaps it could be treated more as a workaround than real solution but this indeed helped to get rid of the excesive memory usage, swapping and basically killing the server.
Thus it seems the problem was PHP and mysql or apache were affected only as a result of poor PHP performance (or poor PHP code, this needs to be investigated since we use a lot of Wordpress plugins which may be causing problems).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.