Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have been running a very small wordpress site on Amazon EC2 for about 2 months, using the free tier micro instance.

I have been getting billed a few dollars each month for going over the disk I/O allowance.

I have looked into how I can reduce the disk I/O, and made some changes such add allowing browser caching of images by changing apache.conf, minimising images and plugins, etc.

I then added APC module to PHP. I expected this to reduce I/O a lot, but it seems to be making no difference.

APC status (apc.php):
http://oi41.tinypic.com/30t5gud.jpg

vmstat output during the load of a single webpage:
http://oi44.tinypic.com/9st2s2.jpg

It seems that there is I/O going on during the load of the webpage. I don't understand why, since the PHP should be in the APC cache and the images are already cached in my browser.

My goal is to simply reduce I/O, and therefore cost. Is there anything I can do to achieve this? For example, is APC setup incorrectly or is there some other technique to avoid I/O?

(PS: W3TC wordpress plugin didnt work for me. I probably didn't install it correctly - it locked me out of the site, overloaded the CPU and brought the site down.)

share|improve this question

2 Answers 2

up vote 3 down vote accepted

We can see that your instance is running very low on memory, and is actually swapping. This is disk I/O for which you'll get billed, and also causes your site to run slower.

Free up some memory by stopping unnecessary processes and tuning your web server to run fewer workers (e.g. Apache or php-fpm).

share|improve this answer
    
Thank you. I know how to reduce the number of workers, but how would I go about finding unnecessary processes? –  z c May 13 '13 at 18:10
    
Look through the process list, know what everything is and whether you need it running. Those almost certainly will give rise to separate questions. –  Michael Hampton May 13 '13 at 18:11
    
I have reduced the apache workers from 20 to 10, and lowered the amount of memory used by some variables in my.cnf. After an apache graceful restart, available memory became 300MB (of total 512MB), however it soon went down to 160MB after an hour. I guess I will keep watching it and hope it doesn't hit zero. –  z c May 13 '13 at 19:54

A few things...

  1. Try something like batcache for Wordpress, as it only caches the pages that are hit frequently and thus reduces some overhead from pre-caching everything

  2. I'd recommend switching to NGINX for your HTTP server if you have very little memory available. It's super efficient.

  3. Check the resource utilization of MySQL. In 99% of cases, it is configured too generously and eats all available server memory.

share|improve this answer
    
Thank you. How would I check the resource utilization of MySQL? –  z c May 13 '13 at 18:09
    
This is a good place to start: github.com/rackerhacker/MySQLTuner-perl, also install something like htop on your server to see what's actively eating up your memory. –  ultraviol3tlux May 14 '13 at 15:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.