Quantcast

Jump to content


Photo

[Case Study] Nginx + PHP-fpm + APC


  • Please log in to reply
7 replies to this topic

#1 iargue

iargue
  • 10048 posts


Users Awards

Posted 08 March 2012 - 04:24 PM

This case study is used to show the difference in execution times and resource usage between using Nginx and fastcgi, and Nginx and php-fpm with apc.

VPS (Provided by MyHosting VPS)
1076 mhz cpu
1056mb ram
100gb space
600gb transfer limit

Test #1: Configuration

Naginx 1.0.5 - Default Settings (2 worker processes, 1024 connections)
Php 5.3.10 through fast cgi - Default Settings
Mysql 5.5 - Default Settings

Php timeout limit 900 seconds, fastcgi timeout settings 900 seconds. Nothing else changed.

Test time 10 minutes
Starting number of concurrent connections, 0. Ending number, 500.

Test #1: Results

See the full test results here - https://loadimpact.c...137ae516b59e212

Memory Usage Start: 275
Memory Usage End: 401

CPU Usage reached 100% usage at 200 concurrent users

Test #2: Configuration
Naginx 1.0.5 - Default Settings (2 worker processes, 1024 connections)
Php 5.3.10 through php-fpm - default settings
Php APC 3.1.9
Mysql 5.5 - Default Settings

Php timeout limit 900 seconds, php-fpm timeout settings 900 seconds. Nothing else changed.

Test time 10 minutes
Starting number of concurrent connections, 0. Ending number, 500.

Test #2: Results

See Full Test Results Here - https://loadimpact.c...47a13ca2e904dcc

Memory Usage Start: 231
Memory Usage End: 271

Cpu usage hit 100% at 400 concurrent connections

Conclusion:

Php-fpm with apc provides significant improvements in both delivery speeds, and resource usage. Using almost 100mb less memory when at 500 concurrent users, and providing much faster connection speeds while under heavy load.

My suggestion. Switch from fastcgi to php-fpm and enable apc. Its deffinately worth it (And switching is easy. Install php-fpm. Install Php apc. Start it. Change your fastcgi pass to 127.0.0.1:9000 and restart nginx, then kill fastcgi and your done. Works in the same exact method, but just better :)

(Even if using another host, php-fpm with apc reduces the strain from php processing. Will improve performance through any method)

Edited by iargue, 08 March 2012 - 04:27 PM.


#2 Waser Lave

Waser Lave

  • 25516 posts


Users Awards

Posted 08 March 2012 - 04:28 PM

k

#3 Pyro699

Pyro699
  • 1542 posts


Users Awards

Posted 08 March 2012 - 04:38 PM

Cool story bra.

#4 ShadowLink64

ShadowLink64
  • 16735 posts


Users Awards

Posted 08 March 2012 - 04:42 PM

You're comparing apples to oranges here.

Where is the opcode cache in the fastcgi setup? Install APC on test case #1 and you'll make a more convincing case.

For all I know, the boost in performance can be attributed to caching of the php alone (though I don't think it is -- php-fpm is known to be faster, but by how much I have no idea).

#5 iargue

iargue
  • 10048 posts


Users Awards

Posted 09 March 2012 - 01:18 AM

You're comparing apples to oranges here.

Where is the opcode cache in the fastcgi setup? Install APC on test case #1 and you'll make a more convincing case.

For all I know, the boost in performance can be attributed to caching of the php alone (though I don't think it is -- php-fpm is known to be faster, but by how much I have no idea).



Adding APC to fastcgi is a terrible idea. Every fastcgi child process gets its own memory core. The memory would be double what it was without APC. Terrible Idea (My APC cache was at 40mb. that times 5 means horrible resource consumption :p)

#6 artificial

artificial
  • 186 posts


Users Awards

Posted 09 March 2012 - 03:52 AM

Tell me, what do you use these web servers for? May I see a website you've developed? :)

edit: actually, last I recall iargue blocked me, so no doubt this message will go unanswered.

Edited by wetfartificial, 09 March 2012 - 03:53 AM.


#7 ShadowLink64

ShadowLink64
  • 16735 posts


Users Awards

Posted 09 March 2012 - 09:42 AM

Adding APC to fastcgi is a terrible idea. Every fastcgi child process gets its own memory core. The memory would be double what it was without APC. Terrible Idea (My APC cache was at 40mb. that times 5 means horrible resource consumption :p)

But, if you're using fastcgi, it does make your site faster when you use APC. :p Therefore, the argument would be to switch to php-fpm just to save memory mostly. Maybe once I'm not so busy (we don't pay for RAM usage anymore, so it's not too pressing of an issue).

#8 iargue

iargue
  • 10048 posts


Users Awards

Posted 09 March 2012 - 09:50 AM

Tell me, what do you use these web servers for? May I see a website you've developed? :)

edit: actually, last I recall iargue blocked me, so no doubt this message will go unanswered.


Spend two seconds looking at the link that I provided for the testing. It tells you my site name.

But, if you're using fastcgi, it does make your site faster when you use APC. :p Therefore, the argument would be to switch to php-fpm just to save memory mostly. Maybe once I'm not so busy (we don't pay for RAM usage anymore, so it's not too pressing of an issue).


Yeah. The main advantage that I see is that fpm saves a lot of resources. I'm going to uninstall APC and see if it uses more memory then with APC enabled (I doubt it). I'll also look at the cpu because we served over a thousand more pages then we did using fastcgi.

I might even use apc with fast cgi just to see how terrible the memory gets.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users