Thursday, February 3, 2011

Why is my server's performance so abysmal

I have an application which is running symfony + wordpress on my development server. The development server is running on the lowest plan at webfaction, which is a shared server that gives me 80MB of RAM.

The site is running apache through mod_fcgid.

The application runs pretty snappy for now on that server.

I ran an ab benchmark:

ab -n 1000 -c 10 http://devserver/

and got 6.33 request/s, which is not the greatest, but the site does seem to be fast enough.

I moved the site to a staging server, which is a VPS with the following specs:

> sysctl hw.physmem
3212058624
> sysctl -a | egrep -i 'hw.machine|hw.model|hw.ncpu'
hw.machine: i386
hw.model: Intel(R) Xeon(TM) CPU 3.20GHz
hw.ncpu: 2
hw.machine_arch: i386

So it seems like a pretty beefy machine. I'm running apache+mod_php, basically out of the box. Sometimes there is a noticeable difference in speed. Sometimes there is incredibly noticeable difference in speed.

I tried the same ab benchmark, and it only got to 20 before it decided that was too much.

Every once in a while, the speed is acceptable, but then I go back to the dev server, and I'm reminded how fast it can run.

Any reason why the app would be running so much slower on a superior box?

  • I recommend to try nginx + php-fpm configuration
    The setup is easy to implement and you may observe a dramatic performance gain (in all regards, speed and resources, easiness of configuration and maintenance).

    See nginx and more precisely the setting of nginx+phpfpm.

    blockhead : I tried php-fpm, but when I started php-fpm, the machine, almost, immediately ran out of memory. I got scared off and didn't want to try again.
    ring0 : You may try a newer version of php-fpm. Also, please have a look to http://nginxphp.wordpress.com/2010/01/28/php-fpm-apc-disk-io/ (for the RAM part).
    blockhead : Newer than the one that ships with php 5.3.3? Does that require patching php, or was the php patch for older versions only because php itself didn't support fpm?
    ring0 : PHP 5.3.3 is new. Did you have a look at the php-fpm options (link) ?
    blockhead : Yes...that's how I installed fpm...with the `--enable-fpm` option.
    From ring0
  • I'm not familiar with Wordpress, but even your dev server performance seems rather poor to me. At a guess I'd say the bottleneck is probably the amount of memory. (but why on earth pay for hosting of a development machine?).

    As for the staging server. No idea. What's 'free' reporting? What's the load? CPU usage? How is apache configured? How long does it take to resolve a single request? For performance this bad, it suggests that the system is hanging around waiting for DNS queries or socket timeouts. What does netstat report? iotop?

    A full explanation of how to investigate and resolve performance problems on Apache and PHP will fill a very large book - so you may not find a definitive answer here on SF.

    From symcbean

0 comments:

Post a Comment