Moving a High Traffic Wordpress Blog from MediaTemple
I have a high traffic wordpress site called tekgoblin.com currently hosted at Mediatemple on their VE servers. It has 512m ram and no swap. Currently when I get slashdotted I can handle the traffic because its cached but I cannot run anything dynamic which is a problem.
I am asking whether or not the 712m vps offered by Linode will be able to handle the hits that I get which you can see at tekgoblin.com/mint.
If so maybe this forum and the beautiful users will be able to help me further optimize it when we cover CES in vegas next January.
Please let me know your opinions or any more information you may need from me.
reposted from a wrong category that I wrongly posted in.
33 Replies
So yes a 512 (or 768 not sure which you want since there's no 712) will be able to handle it, the linode library has some guides on optimising apache/nginx/php/mysql. Also if you search the forums you'll find tons of posts on optimising wordpress.
Not exactly "high traffic" in most books - but I guess it depends on what's being served (a 200k page or a 2G high def movie).
Only way to know for sure - spin up a Linode and see how it works for you.
Lowering that limit can actually increase your performance rather than decrease by avoiding over-committing resources (particularly memory, which causes swapping which is terribly detrimental in the VPS environment).
You may still find performance too slow with the resources on a 512 depending on your application, but letting 50-100 apache processes start and guarantee that you massively swap is definitely going to kill your performance.
– David
@sanity:
Hello,
I have a high traffic wordpress site called tekgoblin.com currently hosted at Mediatemple on their VE servers. It has 512m ram and no swap. Currently when I get slashdotted I can handle the traffic because its cached but I cannot run anything dynamic which is a problem.
I am asking whether or not the 712m vps offered by Linode will be able to handle the hits that I get which you can see at tekgoblin.com/mint.
If so maybe this forum and the beautiful users will be able to help me further optimize it when we cover CES in vegas next January.
Please let me know your opinions or any more information you may need from me.
reposted from a wrong category that I wrongly posted in.
Welcome to Linode! What's up!? I came from MT also.
Wow your traffic really picked up the last two days. Congrats! Nice blog by the way.
In my opinion, I don't think you'll have any problem with the basic $20 Linode. Your best month was 60,351 pageviews, no problem! Unless you're running some crazy-intensive plugins, I bet you could 5x your best month and not notice any difference.
Then again, I'm running Nginx. I actually have no experience with Apache so I can't really compare results for you.
In my experience with WordPress, the main bottleneck is MySQL. It takes up the most memory and most CPU time, by far.
One thing you can do is scatter some little PHP micro-timers throughout your theme to see where you're experiencing slowness with MySQL. I noticed Wordpress.com does this too. This is a good way to find problematic MySQL queries.
For example, I think WordPress has this problem where it doesn't "LIMIT" some selections. So if you have a lot of comments, you might save HOURS of CPU time just adding "LIMIT 50" (or however many comments per page you show) to the "SELECT" in wp-comments.php, or whatever the file is that shows comments.
I'm no longer afraid to hack the "core" of WP now, which is why I won't upgrade my main site to 3.0, LOL. Most of the new stuff they're adding now is cosmetic. Anyway, that's another rant, and I could always upgrade if I had to–just remember to redo the little tweaks here and there.
Anyway, if you get stuck, feel free to IM me on Skype: pjbrunet or email me: pj at pjbrunet.com
@sanity:
Thank you for the message. Today I was unable to access the site for some time and unable to issue commands. Usually there are about 30 apache processes spawning and no ram when this happens and I am in the burstable ram up to 1GB. I shouldnt even be that high I really would like some suggestions on how to fix it if possible. I am not trying to leech I may still need to move to linode but I need a short term solution for now.
By the way, I don't use any "cache" plugins, all my content is dynamic and I do 8,000-10,000 pageviews per day like clockwork and my Linode barely notices. Like this month I never got above 20% CPU, typically peak around 15%. (Granted, a little bit slow for me this month, I'm working on it!) I don't think I'm using much memory either. By my rudimentary calculations, I'll hit Linode's bandwidth limit (which is generous) before I need to think about a second Linode or further tweaking of my database.
I wrote a little blog post showing the microtimer trick (at the bottom)
@sanity:
I am in the burstable ram up to 1GB.
Burstable RAM? Does MT use Virtuozzo/OpenVZ?
Well, welcome to Xen land. Memory works completely differently here. Your mileage may vary, but I generally find that 512MB in Xen is actually a lot more RAM than 512MB in Virtuozzo/OpenVZ.
A few thousand page views per hour is definitely doable on a Linode 512 if you use a good caching plugin for WordPress. It seems you're already using WP Total Cache, so you're all good.
If you're expecting a super traffic spike, you could also upgrade just for a few days and downgrade after the waves have passed.
@sanity:
The problem for me is its very hard to move the site and keep minimal downtime. I am a student and work full time as well.
I don't know why you would have downtime, unless you cancel your MT account before your Linode is ready for traffic. Or maybe if you're using MT as your registrar too?
when using wordpress you should be aware of some bad developed plugins as the cause of performance issues.
I have had a big performance problem using a plugin called wpomatic to import rss feeds from external sites and even on a dedicated server with 4 GB of ram i was forced to reboot more than one time a day due to memory limit reached and no Apache fine tuning solved the issue.
Then i removed the plugin and developed my own php script and it's fine on a Linode 512 vps.
So it would be interesting to see a list of your installed wordpress plugins and discover if some of them is causing your problems or if it is just related to Virtuozzo that shares server resources with other customers.
Moving your wp site to linode is very simple, just backup your database and your wordpress installation, then you can use stack scripts to install a ready to use lamp to your Linode vps, import the mysql backup, import the wordpress installation backup, check that paths, mysql database name, username and password are ok inside the wordpress configuration file, set your domain name inside linode dns manager and when all is ok, change the dns settings from your domain control panel.
Last login: Fri Oct 29 12:16:15 on console
top - 04:20:19 up 1 day, 18:23, 1 user, load average: 0.09, 0.49, 0.36
Tasks: 18 total, 1 running, 17 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.0%sy, 0.0%ni,100.0%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 946344k total, 278976k used, 667368k free, 0k buffers
Swap: 0k total, 0k used, 0k free, 0k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
22234 mysql 15 0 279m 60m 5092 S 0.0 6.6 13:37.22 mysqld
25846 apache 15 0 270m 45m 3496 S 0.0 5.0 0:03.62 httpd
32049 apache 18 0 270m 45m 3480 S 0.0 4.9 0:01.47 httpd
26380 root 15 0 77388 14m 1660 S 0.0 1.5 0:00.25 miniserv.pl
15624 root 18 0 232m 9.9m 5868 S 0.0 1.1 1:01.76 httpd
5288 root 15 0 86064 3436 2660 S 0.0 0.4 0:00.02 sshd
25839 postfix 18 0 117m 2508 1876 S 0.0 0.3 0:00.04 qmgr
25816 root 15 0 54152 2312 1788 S 0.0 0.2 0:00.19 master
3238 postfix 15 0 54216 2288 1788 S 0.0 0.2 0:00.00 pickup
18244 root 18 0 12068 1728 1288 S 0.0 0.2 0:00.02 bash
25886 nobody 18 0 51528 1608 620 S 0.0 0.2 0:00.28 proftpd
22011 root 19 0 11932 1424 1184 S 0.0 0.2 0:00.01 mysqld_safe
21960 root 18 0 62628 1208 648 S 0.0 0.1 0:00.32 sshd
21763 root 15 0 12612 1192 928 R 0.3 0.1 0:00.09 top
25923 root 15 0 20872 1180 588 S 0.0 0.1 0:00.06 crond
1 root 15 0 10352 740 620 S 0.0 0.1 0:01.67 init
19534 root 19 -4 12608 680 360 S 0.0 0.1 0:00.00 udevd
21914 root 15 0 5912 624 500 S 0.0 0.1 0:00.14 syslogd
top - 04:22:07 up 1 day, 18:25, 1 user, load average: 0.11, 0.36, 0.32
top - 04:22:32 up 1 day, 18:25, 1 user, load average: 0.21, 0.37, 0.33
Tasks: 49 total, 1 running, 47 sleeping, 0 stopped, 1 zombie
Cpu(s): 2.7%us, 0.5%sy, 0.0%ni, 96.9%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 946344k total, 946344k used, 0k free, 0k buffers
Swap: 0k total, 0k used, 0k free, 0k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
23891 apache 15 0 298m 45m 3320 S 18.0 4.9 0:00.57 httpd
23911 apache 15 0 305m 43m 3312 S 15.7 4.7 0:00.49 httpd
9769 apache 15 0 270m 45m 3324 S 13.7 4.9 0:02.28 httpd
22234 mysql 18 0 279m 60m 5092 S 0.7 6.5 13:37.66 mysqld
12136 apache 15 0 232m 7180 2472 S 0.3 0.8 0:00.08 httpd
20443 apache 15 0 296m 21m 3060 S 0.3 2.4 0:00.22 httpd
26593 apache 15 0 0 0 0 Z 0.3 0.0 0:00.02 httpd
1 root 15 0 10352 740 620 S 0.0 0.1 0:01.67 init
3238 postfix 18 0 54216 2288 1788 S 0.0 0.2 0:00.00 pickup
3565 apache 15 0 265m 40m 3300 S 0.0 4.4 0:00.64 httpd
3566 apache 15 0 265m 40m 3312 S 0.0 4.4 0:00.56 httpd
5288 root 18 0 86064 3436 2660 S 0.0 0.4 0:00.04 sshd
6078 apache 15 0 268m 43m 3300 S 0.0 4.7 0:02.02 httpd
9765 apache 15 0 265m 40m 3304 S 0.0 4.4 0:00.56 httpd
12115 apache 15 0 329m 40m 3268 S 0.0 4.4 0:01.84 httpd
12122 apache 15 0 265m 40m 3316 S 0.0 4.4 0:00.60 httpd
12157 apache 15 0 265m 40m 3268 S 0.0 4.4 0:00.53 httpd
12168 apache 18 0 274m 49m 3852 S 0.0 5.4 0:02.40 httpd
15624 root 15 0 232m 9.9m 5868 S 0.0 1.1 1:01.85 httpd
15902 apache 15 0 307m 35m 3272 S 0.0 3.8 0:00.38 httpd
18071 apache 15 0 232m 7116 2480 S 0.0 0.8 0:00.02 httpd
18075 apache 15 0 265m 40m 3272 S 0.0 4.4 0:00.50 httpd
18244 root 18 0 12068 1728 1288 S 0.0 0.2 0:00.02 bash
19534 root 19 -4 12608 680 360 S 0.0 0.1 0:00.00 udevd
20428 apache 15 0 273m 49m 3836 S 0.0 5.3 0:01.73 httpd
21914 root 15 0 5912 624 500 S 0.0 0.1 0:00.14 syslogd
21960 root 18 0 62628 1208 648 S 0.0 0.1 0:00.32 sshd
22011 root 19 0 11932 1424 1184 S 0.0 0.2 0:00.01 mysqld_safe
23879 apache 15 0 329m 45m 3308 S 0.0 4.9 0:00.87 httpd
23896 apache 15 0 232m 5720 1220 S 0.0 0.6 0:00.01 httpd
23905 apache 15 0 308m 32m 3292 S 0.0 3.5 0:00.40 httpd
23908 apache 15 0 232m 6960 2340 S 0.0 0.7 0:00.01 httpd
23915 apache 15 0 232m 6988 2352 S 0.0 0.7 0:00.03 httpd
23919 apache 15 0 265m 40m 3268 S 0.0 4.4 0:00.50 httpd
25816 root 15 0 54152 2312 1788 S 0.0 0.2 0:00.19 master
25839 postfix 18 0 117m 2508 1876 S 0.0 0.3 0:00.04 qmgr
25886 nobody 15 0 51528 1608 620 S 0.0 0.2 0:00.28 proftpd
25923 root 15 0 20872 1180 588 S 0.0 0.1 0:00.06 crond
26380 root 15 0 77388 14m 1660 S 0.0 1.5 0:00.25 miniserv.pl
26577 apache 15 0 265m 40m 3276 S 0.0 4.4 0:00.48 httpd
26589 apache 15 0 232m 5728 1224 S 0.0 0.6 0:00.01 httpd
26600 apache 15 0 265m 40m 3264 S 0.0 4.4 0:00.53 httpd
26602 apache 15 0 296m 19m 3016 S 0.0 2.1 0:00.18 httpd
26606 apache 15 0 234m 8952 2940 S 0.0 0.9 0:00.05 httpd
26609 apache 15 0 232m 5736 1232 S 0.0 0.6 0:00.01 httpd
26614 apache 15 0 232m 5724 1220 S 0.0 0.6 0:00.01 httpd
Also, are you using a 64-bit OS? (Apache usually doesn't have VIRT values of over 300M on a 32-bit OS.) Using 64-bit in a VPS with less than 4GB of RAM is a bad idea.
Cut it down to 20.
MinSpareServers 1
MaxSpareServers 1
ServerLimit 20
MaxClients 20
MaxRequestsPerChild 500
Linux version 2.6.18-028stab069.5 (root@rhel5-build-x64) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Tue May 18 17:26:16 MSD 2010
@sanity:
This is what I will set
StartServers 3 MinSpareServers 1
MaxSpareServers 1
ServerLimit 20
MaxClients 20
MaxRequestsPerChild 500
That should be fine you should increase max requests per child unless you're worried about memory leaks from your app.
My advise is to create a linode 512 (32 bit), copy your app to it, then run benchmarks against it (google apache's ab). You're running red hat which linode doesn't supply (it's not free), if you want something similar use centos which is a red hat derivative containing free software.
It'll only cost you a few dollars to test so give it a go!
Super Cache
Why? Super Cache has one thing that Total Cache doesn't. It allows you to completely bypass PHP by serving static versions of your blog to non-logged-in users. This can save you a lot of memory. By comparison, the Total Cache plugin itself is a huge bloated monster with tons of options, all of which takes RAM to load up and execute. I think I've heard of VPS's running out of memory using Total Cache, but I've never heard of VPS's running out of memory using Super Cache.
I don't know how much difference this will make in your particular case, but it's worth a try.
If you're running total cache with CDN, how can you have a problem with 2k page impressions in an hour?
I've just benched my 512 node (nginx with fasctcgi_cache):
Server Software: nginx/0.8.53
Server Port: 80
Document Path: /
Document Length: 45151 bytes
Concurrency Level: 50
Time taken for tests: 57.811294 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 227961725 bytes
HTML transferred: 226703225 bytes
Requests per second: 86.49 [#/sec] (mean)
Time per request: 578.113 [ms] (mean)
Time per request: 11.562 [ms] (mean, across all concurrent requests)
Transfer rate: 3850.77 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 108 113 6.7 112 148
Processing: 444 460 31.1 448 1356
Waiting: 108 112 10.2 112 252
Total: 556 573 31.2 564 1468
Percentage of the requests served within a certain time (ms)
50% 564
66% 584
75% 584
80% 584
90% 588
95% 596
98% 604
99% 668
100% 1468 (longest request)
[edit]I put in the wrong results, they weren't cached either. Have added cached result. No siginificant load or ram usage during bench.[/edit]
I'll let someone else comment on whether those are good results not not.
@sanity:
Like right now, the site is slashdotted again and the site is almost unresponsive. I want to know if swap will fix that.
@sanity:
http://imgur.com/LKd0w.png
You still have plenty of RAM left; your CPU usage is low; and there's no IO contention ("wa"). I don't see any reason in that picture why the site would be unresponsive.
Do you have any plugins that connect to a remote service (e.g. Twitter) at every page view?
Anything in the MySQL slow query log
Also, it seems you haven't switched to Linode yet. There's a limit to what we Linoders can do to help you solve a non-Linode problem. For all we know, the problem might have to do with an overloaded host machine or the virtualization technology. Memory management in Xen is completely different from Virtuozzo/OpenVZ.
[root@tekgoblin ~]# mysqldumpslow
Can't determine basedir from 'myprintdefaults mysqld' output: –datadir=/var/lib/mysql
--socket=/var/lib/mysql/mysql.sock
--user=mysql
--old_passwords=1
--longquerytime=1
--log-slow-queries=/var/log/mysql/mysql-slow.log
--max_connections=300
--key_buffer=32M
--myisamsortbuffer_size=32M
--joinbuffersize=1M
--readbuffersize=1M
--sortbuffersize=2M
--table_cache=4000
--threadcachesize=286
--interactive_timeout=25
--wait_timeout=7000
--connect_timeout=10
--maxallowedpacket=16M
--maxconnecterrors=10
--querycachelimit=2M
--querycachesize=12M
--querycachetype=1
--tmptablesize=16M
--skip-innodb
[root@tekgoblin ~]#
However and I typed this, this happened:
The culprit, as usual, is Apache. It's using 700-800MB of RAM according to your last screenshot. With 24 heavyweight children, this is only to be expected. There really are very few options, all of which has already been discussed. Cache the hell out of everything, drop unnecessary WordPress plugins, and reduce MaxClients/ServerLimit. (Reducing the max requests per child only helps if the PHP engine itself has a memory leak, which is unlikely nowadays.)
Most importantly, set up a Linode 768 or 1024 and run some stress tests. It's been 6 weeks since you've been posting here, so there's no reason not to try a Linode already. If you're not satisfied with the results, you know Linode has a 7-day money back guarantee.