Help me configure my Apache and MySQL Settings for Better Performance

robdog

Well-known member
I have an 8GB Linode server and I do not believe its resource are getting properly allocated. I am running Apache Benchmark with the following command:
ab -kc 100 -n 1000 http://www.mydomain.com/

It completes, but I only get 9 requests/second. Which IMO is pretty bad. The one thing I notice while running the top command is that the memory usage did not go about 3GB. (leaving 5GB is reserve ready to use) However, the CPU utilization when through the roof. And the home page has maybe 5-6 MySQL queries. (which I could reduce down to about 1-2, but anyways.)

Here are some of my Apache conf settings:
Code:
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers      5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild  0
</IfModule>
 
<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
 
<IfModule mpm_event_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

Would increasing the number of Apache server help with the crazy CPU utilization and response times? Or is there another Apache setting that I should look at?

Also, here are some of my MySQL settings:
Code:
key_buffer              = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
query_cache_limit       = 1M
query_cache_size        = 16M
 
[mysqldump]
quick
quote-names
max_allowed_packet      = 16M

Finally, I am running Ubuntu 12.04 64-bit.

Thanks for any input!
 
Something strange is up if a few mysql queries runs your CPU out!
My older forum used 50+ sql queries on some pages and it didn't slow anything down, even with 2gig of RAM.

I don't know about all those various apache module settings - mine doesn't have the "ifs"......but the basics I have set are:
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
MinSpareServers 5
MaxSpareServers 20
StartServers 12
MaxServers 50
MaxClients 256
MaxRequestsPerChild 4000 (you could probably greatly lower this and maxclients, etc.)

That's with 8 gig of RAM, and even with hundreds of users at one time, httpd requests never take up very much of the CPU. You didn't mention how much actual CPU you have.....

As to mysql, XF (if that is what you use) uses innodb, so you have to set the conf specifically for some aspects of innodb.

But you may have to start with some basics - like being sure php is run as mod_php under apache, etc.

In general, the default cnfs for mysql should at least get things working to a better degree than you have...

Please report back when you figure out the culprit.
 
I have increased a number of the Apache settings but still running into the same problem. I am going to start messing with the MySQL settings to see if this is the issue. Also, this site does not run XenForo.
 
Okay so I figured out what the culprit was. PHPLess was causing an issue and was running on every page load. I have moved this to a one off when I deploy something new for the CSS files. I am not getting up to 85 requests/second now on the 8GB linode. Almost makes me wonder if I should move to the 4GB! :p
 
Top Bottom