Greetings,
I have a WP site with over than 150k pageviews /day.
It’s running on a Intel Core i5 CPU 760 @ 2.80GHz, with Centos and 4 GB of RAM.
The problem is WP consumes too much RAM and after a while serve gets overloaded and RAM runs out. I’ve tried many Apache tweeks but nothing seems to work. After I restart Apache site will run smoothly but after an hour or two it will get overloaded again.
Do any of you guys have any tip that will help me?
BTW, I’m using WP-Super Cache.
UPDATE: Aditional info
Here’s my list of plugins:
- Akismet
- Contact Form 7
- Domain Mirror
- Faster Image Insert
- IntenseDebate
- Role Manager
- SexyBookmarks
- Smart Youtube
- Star Rating for Reviews
- Thumbnail For Excerpts
- WP-Polls
- WP-SWFObject
- WP Super Cache
As for the tweeks, I’ve tried some tips from here
My settings are:
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 200
MaxRequestsPerChild 1000
</IfModule>
<IfModule worker.c>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 1000
</IfModule>
Timeout 120 KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 2
Also here’s my my.cnf
[mysqld]
set-variable=local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
UPDATE
Here’s my current memory usage
ps -ylC httpd --sort:rss
S UID PID PPID C PRI NI RSS SZ WCHAN TTY TIME CMD
S 504 8446 8444 0 78 0 7884 59507 554050 ? 00:00:00 httpd
S 504 29164 8444 0 78 0 13380 87043 - ? 00:00:00 httpd
S 504 29268 8444 0 75 0 13396 87043 429493 ? 00:00:00 httpd
S 504 29294 8444 0 75 0 13396 87043 - ? 00:00:00 httpd
S 504 29255 8444 0 75 0 13400 87043 - ? 00:00:00 httpd
S 504 29269 8444 0 76 0 13400 87043 387946 ? 00:00:00 httpd
S 504 29256 8444 0 75 0 13404 87043 - ? 00:00:00 httpd
S 504 29265 8444 0 75 0 13404 87043 - ? 00:00:00 httpd
S 504 29288 8444 0 75 0 13404 87043 429493 ? 00:00:00 httpd
S 504 28644 8444 0 75 0 13484 87043 - ? 00:00:00 httpd
S 504 29293 8444 0 75 0 13484 87043 semtim ? 00:00:00 httpd
S 504 27280 8444 0 75 0 13496 87043 - ? 00:00:00 httpd
S 504 28332 8444 0 75 0 13500 87043 - ? 00:00:00 httpd
S 504 27762 8444 0 75 0 13504 87043 - ? 00:00:00 httpd
S 504 28645 8444 0 75 0 13504 87043 - ? 00:00:00 httpd
S 504 29242 8444 0 75 0 13508 87043 - ? 00:00:00 httpd
S 504 28199 8444 0 75 0 13512 87043 429493 ? 00:00:00 httpd
S 504 28195 8444 0 75 0 13528 87043 - ? 00:00:00 httpd
S 504 28197 8444 0 75 0 13528 87043 429493 ? 00:00:00 httpd
S 504 27245 8444 0 75 0 13536 87043 - ? 00:00:00 httpd
S 504 28196 8444 0 75 0 13536 87043 - ? 00:00:00 httpd
S 504 27756 8444 0 75 0 13540 87043 - ? 00:00:00 httpd
S 504 27969 8444 0 75 0 13540 87043 - ? 00:00:00 httpd
S 504 27074 8444 0 75 0 13544 87043 - ? 00:00:00 httpd
S 504 27279 8444 0 75 0 13544 87043 - ? 00:00:00 httpd
S 504 27926 8444 0 75 0 13548 87043 - ? 00:00:00 httpd
S 504 28191 8444 0 75 0 13548 87043 semtim ? 00:00:00 httpd
S 504 28673 8444 0 75 0 13548 87043 - ? 00:00:00 httpd
S 504 27089 8444 0 75 0 13552 87043 - ? 00:00:00 httpd
S 504 27825 8444 0 75 0 13552 87043 - ? 00:00:00 httpd
S 504 27974 8444 0 75 0 13552 87043 - ? 00:00:00 httpd
S 504 28330 8444 0 75 0 13552 87043 - ? 00:00:00 httpd
S 504 26051 8444 0 75 0 13556 87043 - ? 00:00:00 httpd
S 504 28343 8444 0 75 0 13556 87043 - ? 00:00:00 httpd
S 504 26822 8444 0 75 0 13560 87043 - ? 00:00:00 httpd
S 504 27975 8444 0 75 0 13560 87043 - ? 00:00:00 httpd
S 504 28662 8444 0 75 0 13560 87043 - ? 00:00:00 httpd
S 504 24949 8444 0 75 0 13564 87043 - ? 00:00:00 httpd
S 504 28639 8444 0 75 0 13564 87043 - ? 00:00:00 httpd
S 504 24924 8444 0 75 0 13572 87043 - ? 00:00:00 httpd
S 504 27826 8444 0 75 0 13572 87043 - ? 00:00:00 httpd
S 504 28192 8444 0 75 0 13572 87043 - ? 00:00:00 httpd
S 504 28683 8444 0 76 0 13572 87043 - ? 00:00:00 httpd
S 504 19032 8444 0 75 0 13576 87043 - ? 00:00:00 httpd
S 504 26832 8444 0 75 0 13576 87043 - ? 00:00:00 httpd
S 504 28186 8444 0 75 0 13580 87043 - ? 00:00:00 httpd
S 504 24940 8444 0 75 0 13584 87043 - ? 00:00:00 httpd
S 504 27883 8444 0 75 0 13584 87043 - ? 00:00:00 httpd
S 504 27962 8444 0 75 0 13588 87043 - ? 00:00:00 httpd
S 504 28331 8444 0 75 0 13588 87043 - ? 00:00:00 httpd
S 504 18521 8444 0 75 0 13592 87043 - ? 00:00:00 httpd
S 504 24291 8444 0 75 0 13592 87043 - ? 00:00:00 httpd
S 504 24307 8444 0 75 0 13592 87043 - ? 00:00:00 httpd
S 504 26503 8444 0 75 0 13592 87043 - ? 00:00:00 httpd
S 504 26510 8444 0 75 0 13592 87043 - ? 00:00:00 httpd
S 504 27100 8444 0 75 0 13592 87043 - ? 00:00:00 httpd
S 504 27248 8444 0 75 0 13592 87043 429493 ? 00:00:00 httpd
S 504 28344 8444 0 75 0 13592 87043 429493 ? 00:00:00 httpd
S 504 24952 8444 0 75 0 13596 87043 - ? 00:00:00 httpd
S 504 26588 8444 0 75 0 13596 87043 - ? 00:00:00 httpd
S 504 27065 8444 0 75 0 13596 87043 - ? 00:00:00 httpd
S 504 27102 8444 0 75 0 13600 87043 - ? 00:00:00 httpd
S 504 27104 8444 0 75 0 13600 87043 429493 ? 00:00:00 httpd
S 504 27474 8444 0 75 0 13600 87043 429493 ? 00:00:00 httpd
S 504 27763 8444 0 75 0 13600 87043 - ? 00:00:00 httpd
S 504 23657 8444 0 75 0 13604 87043 - ? 00:00:00 httpd
S 504 24311 8444 0 75 0 13604 87043 - ? 00:00:00 httpd
S 504 24790 8444 0 75 0 13604 87043 - ? 00:00:00 httpd
S 504 25731 8444 0 75 0 13604 87043 - ? 00:00:00 httpd
S 504 27087 8444 0 75 0 13604 87043 - ? 00:00:00 httpd
S 504 24473 8444 0 75 0 13608 87043 - ? 00:00:00 httpd
S 504 27976 8444 0 75 0 13612 87043 - ? 00:00:00 httpd
S 504 28163 8444 0 75 0 13620 87043 - ? 00:00:00 httpd
S 504 29266 8444 0 75 0 14204 87043 - ? 00:00:00 httpd
S 504 17701 8444 0 75 0 14392 87043 - ? 00:00:00 httpd
S 504 27881 8444 0 75 0 14408 87043 - ? 00:00:00 httpd
S 504 26593 8444 0 75 0 14412 87043 - ? 00:00:00 httpd
S 504 27072 8444 0 76 0 14428 87043 - ? 00:00:00 httpd
S 504 17704 8444 0 75 0 15028 87043 - ? 00:00:00 httpd
S 504 28674 8444 0 75 0 17076 87299 - ? 00:00:00 httpd
S 504 23649 8444 0 75 0 17180 87299 - ? 00:00:00 httpd
S 504 21484 8444 0 75 0 17232 87299 429493 ? 00:00:00 httpd
S 504 24034 8444 0 75 0 17240 87299 - ? 00:00:00 httpd
S 504 24941 8444 0 75 0 17248 87299 - ? 00:00:00 httpd
S 504 27058 8444 0 75 0 17256 87299 - ? 00:00:00 httpd
S 504 24766 8444 0 75 0 17272 87299 - ? 00:00:00 httpd
S 504 28333 8444 0 75 0 17284 87299 semtim ? 00:00:00 httpd
S 504 20565 8444 0 75 0 17296 87299 semtim ? 00:00:00 httpd
S 504 25462 8444 0 75 0 17296 87299 - ? 00:00:00 httpd
S 504 28201 8444 0 75 0 17296 87299 - ? 00:00:00 httpd
S 504 28202 8444 0 75 0 17316 87299 - ? 00:00:00 httpd
S 504 27968 8444 0 75 0 17328 87299 - ? 00:00:00 httpd
S 504 27973 8444 0 75 0 17328 87299 - ? 00:00:00 httpd
S 504 24091 8444 0 75 0 17336 87299 429493 ? 00:00:00 httpd
S 504 28329 8444 0 75 0 17344 87299 - ? 00:00:00 httpd
S 504 27885 8444 0 75 0 17352 87299 - ? 00:00:00 httpd
S 504 21556 8444 0 75 0 17356 87299 semtim ? 00:00:00 httpd
S 504 24121 8444 0 75 0 17356 87299 429493 ? 00:00:00 httpd
S 504 24929 8444 0 75 0 17356 87299 - ? 00:00:00 httpd
S 504 27918 8444 0 75 0 17356 87299 - ? 00:00:00 httpd
S 504 24778 8444 0 75 0 17360 87299 - ? 00:00:00 httpd
S 504 27075 8444 0 75 0 17360 87299 - ? 00:00:00 httpd
S 504 20603 8444 0 75 0 17364 87299 - ? 00:00:00 httpd
S 504 24031 8444 0 75 0 17364 87299 429493 ? 00:00:00 httpd
S 504 24791 8444 0 75 0 17364 87299 - ? 00:00:00 httpd
S 504 26509 8444 0 75 0 17364 87299 - ? 00:00:00 httpd
S 504 27249 8444 0 75 0 17364 87299 - ? 00:00:00 httpd
S 504 24148 8444 0 75 0 17372 87299 - ? 00:00:00 httpd
S 504 24777 8444 0 75 0 17372 87299 - ? 00:00:00 httpd
S 504 24472 8444 0 75 0 17392 87299 semtim ? 00:00:00 httpd
S 504 24789 8444 0 75 0 17432 87299 429493 ? 00:00:00 httpd
S 504 27066 8444 0 75 0 17432 87299 429493 ? 00:00:00 httpd
S 504 27106 8444 0 75 0 17452 87299 - ? 00:00:00 httpd
S 504 26508 8444 0 75 0 17472 87299 - ? 00:00:00 httpd
S 504 24168 8444 0 75 0 17488 87299 - ? 00:00:00 httpd
S 504 22355 8444 0 75 0 17492 87299 - ? 00:00:00 httpd
S 504 23656 8444 0 75 0 17844 87555 - ? 00:00:00 httpd
S 504 27088 8444 0 75 0 17888 87555 - ? 00:00:00 httpd
S 504 28198 8444 0 75 0 17900 87555 - ? 00:00:00 httpd
S 504 26694 8444 0 75 0 17960 87555 - ? 00:00:00 httpd
S 0 8444 1 0 78 0 20276 87043 - ? 00:00:00 httpd
S 504 27271 8444 0 75 0 28796 90883 - ? 00:00:00 httpd
S 504 19949 8444 0 75 0 28888 90883 - ? 00:00:00 httpd
S 504 25736 8444 0 75 0 29840 91395 - ? 00:00:00 httpd
S 504 27086 8444 0 75 0 29848 91395 - ? 00:00:00 httpd
S 504 26606 8444 0 75 0 29856 91395 429493 ? 00:00:00 httpd
S 504 24159 8444 0 75 0 29876 91395 - ? 00:00:00 httpd
S 504 26821 8444 0 75 0 29876 91395 - ? 00:00:00 httpd
S 504 26815 8444 0 75 0 29932 91395 - ? 00:00:00 httpd
S 504 27418 8444 0 75 0 29940 91395 - ? 00:00:00 httpd
S 504 27426 8444 0 75 0 29944 91395 semtim ? 00:00:00 httpd
S 504 27468 8444 0 75 0 29948 91395 - ? 00:00:00 httpd
S 504 26587 8444 0 75 0 29952 91395 - ? 00:00:00 httpd
S 504 24486 8444 0 75 0 29956 91395 semtim ? 00:00:00 httpd
S 504 24951 8444 0 75 0 29956 91395 429493 ? 00:00:00 httpd
S 504 24180 8444 0 75 0 29960 91395 - ? 00:00:00 httpd
S 504 24305 8444 0 75 0 29972 91395 - ? 00:00:00 httpd
S 504 24467 8444 0 75 0 30008 91395 - ? 00:00:00 httpd
S 504 26507 8444 0 75 0 30032 91395 semtim ? 00:00:00 httpd
S 504 24460 8444 0 75 0 30056 91651 - ? 00:00:00 httpd
S 504 23669 8444 0 75 0 30076 91395 - ? 00:00:00 httpd
S 504 26580 8444 0 75 0 30088 91651 - ? 00:00:00 httpd
S 504 23112 8444 0 75 0 30172 91395 - ? 00:00:00 httpd
S 504 26607 8444 0 75 0 30192 91395 - ? 00:00:00 httpd
S 504 24772 8444 0 75 0 30212 91395 - ? 00:00:00 httpd
S 504 24942 8444 0 75 0 30216 91395 - ? 00:00:00 httpd
S 504 24167 8444 0 75 0 30220 91395 - ? 00:00:00 httpd
S 504 26478 8444 0 75 0 30228 91395 - ? 00:00:00 httpd
S 504 24184 8444 0 75 0 30260 91395 429493 ? 00:00:00 httpd
S 504 27425 8444 0 75 0 30292 91395 - ? 00:00:00 httpd
S 504 22348 8444 0 75 0 30388 91651 - ? 00:00:00 httpd
S 504 26605 8444 0 75 0 30396 91651 - ? 00:00:00 httpd
S 504 22678 8444 0 75 0 30420 91395 - ? 00:00:00 httpd
S 504 24489 8444 0 75 0 30452 91395 153384 ? 00:00:00 httpd
S 504 24296 8444 0 75 0 30480 91395 - ? 00:00:00 httpd
S 504 24095 8444 0 75 0 30600 91651 - ? 00:00:00 httpd
S 504 23085 8444 0 75 0 30688 91651 - ? 00:00:00 httpd
S 504 19586 8444 0 75 0 30768 91395 - ? 00:00:00 httpd
S 504 24182 8444 0 75 0 30768 91395 - ? 00:00:00 httpd
S 504 18511 8444 0 75 0 30820 91395 - ? 00:00:00 httpd
S 504 26594 8444 0 75 0 30836 91395 - ? 00:00:00 httpd
S 504 13358 8444 0 75 0 30856 91651 - ? 00:00:00 httpd
S 504 17681 8444 0 75 0 30988 91395 - ? 00:00:00 httpd
S 504 22336 8444 0 75 0 31016 91651 - ? 00:00:00 httpd
S 504 15690 8444 0 75 0 31040 91395 - ? 00:00:00 httpd
S 504 22718 8444 0 75 0 31072 91651 - ? 00:00:00 httpd
S 504 19043 8444 0 75 0 31080 91395 - ? 00:00:00 httpd
S 504 12815 8444 0 75 0 31108 91651 - ? 00:00:00 httpd
S 504 23301 8444 0 75 0 31112 91395 - ? 00:00:00 httpd
S 504 24183 8444 0 75 0 31164 91395 - ? 00:00:00 httpd
S 504 22670 8444 0 75 0 31180 91395 - ? 00:00:00 httpd
S 504 22327 8444 0 75 0 31216 91651 - ? 00:00:00 httpd
S 504 21489 8444 0 75 0 31220 91395 - ? 00:00:00 httpd
S 504 21474 8444 0 75 0 31284 91395 - ? 00:00:00 httpd
S 504 21596 8444 0 75 0 31296 91651 - ? 00:00:00 httpd
S 504 22690 8444 0 75 0 31448 91395 - ? 00:00:00 httpd
S 504 26595 8444 0 75 0 31452 91651 429493 ? 00:00:00 httpd
S 504 20312 8444 0 75 0 31476 91651 429493 ? 00:00:00 httpd
S 504 24313 8444 0 75 0 31592 91397 - ? 00:00:00 httpd
S 504 24179 8444 0 75 0 31696 91395 - ? 00:00:00 httpd
S 504 22369 8444 0 76 0 31732 88329 - ? 00:00:00 httpd
S 504 13373 8444 0 75 0 31768 91395 429493 ? 00:00:00 httpd
S 504 17667 8444 0 75 0 31960 91651 429493 ? 00:00:00 httpd
S 504 18517 8444 0 75 0 32012 91651 - ? 00:00:00 httpd
S 504 7793 8444 0 75 0 32040 91651 - ? 00:00:00 httpd
S 504 17658 8444 0 75 0 32116 91395 - ? 00:00:00 httpd
S 504 27272 8444 0 75 0 32224 91395 - ? 00:00:00 httpd
S 504 13901 8444 0 75 0 32784 91395 - ? 00:00:00 httpd
S 504 15366 8444 0 75 0 33168 91651 - ? 00:00:00 httpd
S 504 24577 8444 0 75 0 33256 88085 - ? 00:00:00 httpd
S 504 14330 8444 0 75 0 34192 91651 - ? 00:00:00 httpd
S 504 15155 8444 0 75 0 34296 91395 - ? 00:00:00 httpd
S 504 16312 8444 0 75 0 34496 91395 - ? 00:00:00 httpd
S 504 28194 8444 0 75 0 36996 88848 - ? 00:00:00 httpd
S 504 24776 8444 0 75 0 43720 92169 429493 ? 00:00:00 httpd
S 504 20584 8444 0 75 0 44224 92169 - ? 00:00:00 httpd
S 504 22331 8444 0 75 0 44636 91913 - ? 00:00:00 httpd
S 504 24033 8444 0 75 0 45496 91664 - ? 00:00:00 httpd
S 504 22375 8444 0 75 0 46320 91664 - ? 00:00:00 httpd
S 504 22378 8444 0 75 0 50064 91664 - ? 00:00:00 httpd
S 504 24481 8444 0 75 0 53836 93968 - ? 00:00:00 httpd
S 504 22354 8444 0 75 0 62124 93962 - ? 00:00:00 httpd
Doest that change what you would recommend me?
Souljacker,
I would first take a look at your plugins. Star Ratings for Reviews hasn’t been updated for over 3 years and looks like its real heavy on the db. I saw some raw sql with some INNER JOINS that look troublesome.
On the server side you should implement some object caching. APC is the defacto standard and will give you the best results.
Once you get APC installed switch to W3 Total Cache or Mark Jaquith’s APC Object Cache Backend to take full advantage of it.
Your httpd.conf settings look fine. From the looks of your my.cnf, your not taking advantage of MySQL query caching, thread caching, or controlling any of the buffer sizes.
You can use a tuning script to help you with your my.cnf configuration. I like to use mysqltuner and tuning primer is also very good.
Mysqltuner will output suggestions and give you some guidlines on what to adjust based on your database usage.
On my server with 12G Ram my settings look like this. (Just an example don’t use these settings!!!)
Like others have mentioned running Nginx will drastically reduce the load on your server if your up to taking on the configurations etc. I wrote a tutorial on how to install and set up Apache with Nginx as a reverse proxy
Hope this helps.
Take a look here: Performance tips for a large user base – it’s a useful set of things to look at that go beyond just Apache.
When looking to optimise performance, it’s pretty important to look at the entire infrastructure to see where you might have issues – for example one of of my sites I eventually traced an issue that initially looked like an Apache problem (apache running out of memory under medium load) to a slow SQL query that was fixed by adding an extra index to the comments table.
Also, install APC or some other PHP op-code cache.
[Update]
It’s quite likely that your MaxClients setting may be too high – if all 200 processes are active and if they’re averaging around 20MB per process, that’s your 4GB used up, without taking into account MySQL and all the other processes. Reduce the MaxCients setting, and continue to investigate where your actual problem is.
You can check on how much memory each Apache process is using with this:
(replace apache2 for httpd if you’re on Ubuntu)
Compare Nginx and Apache and make a choice:
I just switched from Apache to Nginx and it’s about 10 minutes work:
done.
I also went to php-fpm in the same go also about 20 minutes work:
done
(adding /etc/init.d startup files where needed)
I have not run performance tests myself I just follow blindly the “rest of them”
Out of Scope for this answer: Im also planning to ditch MySQL and use MariaDB (GPL) instead.
Working with prefork and Worker configurations is a tricky thing, altering some values will definitely helps in increase of performance and reduce in RAM usage, also please do remember that apache reserves some RAM, that doesn’t mean that your are running out of RAM. Check this article for best optimization advices.