Max Clients Causing Slow Server?
My question is can having such a low max clients cause your server to be really slow?
Many of my users are complaining of slow load times of over 20 seconds. A few are basically getting timed out, or clicking away before the site loads. Could this be caused by max clients or is it something else?
Here's my site url: http://thewritepractice.com
Thanks!
5 Replies
top - 23:06:58 up 24 days, 23:23, 1 user, load average: 0.24, 0.53, 0.44
Tasks: 97 total, 2 running, 95 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.8%us, 0.2%sy, 0.0%ni, 97.9%id, 1.1%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 524512k total, 459528k used, 64984k free, 19512k buffers
Swap: 262136k total, 48k used, 262088k free, 285840k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8597 www-data 15 0 24240 7368 3452 S 1 1.4 0:02.53 apache2
8601 www-data 15 0 24052 7252 3408 S 1 1.4 0:00.90 apache2
8562 www-data 15 0 24936 8184 3512 S 0 1.6 0:05.41 apache2
1434 mysql 23 0 61136 39m 4708 S 0 7.7 268:55.03 mysqld
8574 www-data 15 0 24004 7256 3452 S 0 1.4 0:03.30 apache2
8581 www-data 16 0 24780 7780 3432 S 0 1.5 0:05.31 apache2
8657 www-data 16 0 23972 7124 3364 S 0 1.4 0:00.02 apache2
8655 www-data 15 0 25288 8248 3408 S 0 1.6 0:00.12 apache2
...
The RES value is the physical memory used by the process, and SHR is memory potentially shared with other processes. So RES minus SHR gives you a rough idea of how much memory each additional apache2 process will need (in this case, around to 3800 to 4800 KB or 3.7 to 4.7 MB).
Now you need to determine how much additional memory is available on your system.
$ ps aux | grep -c '^www-data' ; free -m
11
total used free shared buffers cached
Mem: 512 444 67 0 18 280
-/+ buffers/cache: 145 367
Swap: 255 0 255
The ps aux | grep -c '^www-data' tells you how many Apache processes are running (on Debian and Ubuntu servers; on CentOS use ps aux | grep -c '^apache'). In this case, there are 11. As explained by
Of course, you probably are running other services (e-mail, database, etc.) on this machine and don't want to fill the memory completely with Apache processes, so leave yourself a cushion. I have MaxClients set to 60 on this example machine and that keeps it from running into swap.
You can check this by running free -m during a time when your server is getting lots of traffic (either naturally, or you can use a tool like ab to make it busy) and seeing that you still have some memory left in the "free" column.
Note that readers are also downloading the following CSS and javascript files:
/wp-content/themes/Tribe/style.css
/wp-content/plugins/contact-form-7/includes/css/styles.css?ver=3.3.1
/wp-content/plugins/jetpack/modules/widgets/widgets.css?ver=20121003
/wp-content/plugins/jetpack/modules/sharedaddy/sharing.css?ver=2.0.2
/wp-content/plugins/wp-greet-box/css/style.css?ver=3.4.2
/wp-includes/js/jquery/jquery.js?ver=1.7.2
/wp-content/plugins/wp-greet-box/js/functions.js?ver=3.4.2
/wp-content/plugins/wp-greet-box/js/js-mode.js?ver=3.4.2
/wp-content/themes/Tribe/js/jquery.js
/wp-content/themes/Tribe/js/site.js
/wp-content/themes/Tribe/js/lavalamp.js
/wp-content/plugins/contact-form-7/includes/js/jquery.form.min.js?ver=3.18
/wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=3.3.1
/wp-content/themes/genesis/lib/js/menu/superfish.js?ver=1.4.8
/wp-content/themes/genesis/lib/js/menu/superfish.args.js?ver=1.8.2
…plus additional scripts from Google, Twitter, Facebook, Disqus, etc. I haven't bothered checking how much this all adds up to, but it might be slowing things down for people.
Your browser's developer tools will have a "Network" tab which will show this in real time.