Posted by Everett Zufelt on December 22, 2011 at 1:29pm
I'm in the process of moving a couple of sites to an Amazon ec2 microinstance. For the little traffic these sites get the microinstance will be suitable.
I am optimizing performance, and am using mod_fastcgi, php-fpm, and apc; along with varnish.
I have setup a separate fpm pool for each site, but they both appear to share the same apc instance, likely as apc is attached to the fpm process and not the pool.
Is there a method of using a separate apc instance per fpm pool? Or, can someone suggest a setup that is as performant, but which would allow for separate apc instances per site?
Comments
Possible solution
The solution that appears to be the most appealing right now is to run two instances of php-fpm with one pool each.
"just launch php-fpm -y /path/to/php-fpm.conf with different path to php-fpm.conf. The FPM master process consumes almost no CPU and some memory. So multipliing FPM instance is not a big deal. go ahead."
http://forum.nginx.org/read.php?3,122844
Accessibility Consultant & Web Developer - Zufelt.ca
@ezufelt on Twitter | LinkedIn profile
My solution
Here is what I've done (stock install of Ubuntu 11.10).
// Create a second php5-fpm conf file
$ cd /etc/php5/fpm
$ cp php5-fpm.conf php5-fpm-b.conf
// Modify the conf files to load only one pool.
...
;include=/etc/php5/fpm/pool.d/*.conf
include=/etc/php5/fpm/pool.d/name-of-pool-file.conf
// Create a second php5-fpm service
$ cd /etc/init.d
$ cp php5-fpm php5-fpm-b
// Modify the following lines in php5-fpm-b
...
DAEMON_ARGS="--fpm-config /etc/php5/fpm/php-fpm-b.conf"
PIDFILE=/var/run/php5-fpm-b.pid
TIMEOUT=30
SCRIPTNAME=/etc/init.d/$NAME-b
...
// Restart / start the services
$ service php5-fpm restart
$ service php5-fpm-b start
Accessibility Consultant & Web Developer - Zufelt.ca
@ezufelt on Twitter | LinkedIn profile
Memory
IMO the big performance issue with t1.micro instances is memory. The limited amount of RAM (613MB) is an issue, and you combine that with no ephemeral disk means no swap partition. You could build swap on an EBS volume but it's going to be pretty slow and you will pay for both disk and IO.
I run a few Drupal sites on a tiny instance, and my method was to ditch varnish and use just nginx as both a webserver and cache. There is a Drupal Group for Nginx on here with very good working config examples. I also run the database on a different server, so the entire amount of RAM is available to the web server. I also use CloudFront for all static files with the CDN module to completely eliminate those hits to the instance. Even with that, it still bogs down from time to time. But it's livable as a small server.
You mentioned APC. I also use the APC module, which in Drupal 7 can use both the opcode cache as well as the Memcache-like user cache. Right now I am sharing APC with the sites.
Lastly, you may want to consider NewRelic, and specifically their free offering if you aren't into dropping the cash for it. The free server and app monitoring is quite helpful at watching those instances.