« Stuff The Internet Says On Scalability For July 5, 2013 | Main | PRISM: The Amazingly Low Cost of ­Using BigData to Know More About You in Under a Minute »
Wednesday
Jul032013

5 Rockin' Tips for Scaling PHP to 30,000 Concurrent Users Per Server

Jonathan Block, CTO at RockThePost.com, a crowdfunding company, has written a nice set of tips for smaller sites on how to scale a service on EC2 using a small two person development team. 

Their service has a typical small scale structure:

  • PHP's Zend Framework 2
  • Two m1.medium for web servers
  • ELB to split the load
  • master/slave MySQL database
  • Siege for load testing

The very sensible tips that can handle 30,000 concurrent users per web server: 

  • Use PHP's APC feature. APC is opcode cache that is "really a requirement in order for a website to have a chance at performing well."
  • Put everything that's not a .php request on a CDN. Don't serve static files from your web server. They put everything on S3 and use CloudFront as their CDN. Recent CloudFront problems have caused them to serve directly from S3.
  • Don't make connections to other servers in your PHP code. Making connections to other servers blocks the server and slows down processing. Use the APC key/value store for data storage and Varnish for caching full pages.
  • Use Varnish. Using Varnish mage the single biggest difference to their performance under a load test. 
  • Use a c1.xlarge. The c1.xlarge has 8 CPUs which really helps under load. The m1.medium has only 1 CPU for processing requests.

Pretty straightforward, yet good advice. The original article has many more details and is well worth reading.  

Reader Comments (7)

Interesting. Goes to show how far behind we are. Our current application has around 6 c1.xlarge and 10 fm.medium servers. And it runs pretty slow with about a 100 users. Will read the full article.

July 4, 2013 | Unregistered Commenterjarrett

But that is just the exterior site. Original article states that once users sign into the site into the 'interior' it only handles 1,000 per server? That's not very much..

July 4, 2013 | Unregistered CommenterWarren

Jarrett,

Whats your site?

Jon

July 5, 2013 | Unregistered Commenterjon

I'm shocked to not see PHP-FPM mentioned in this post. Is it so de-facto now that everyone presumes its being used, or (more likely given APC is mentioned) was it overlooked entirely? The performance benefits of PHP-FPM, even within Apache, are astonishing and I'd literally expect a 2x performance boost for all PHP rendered files without any other changes being necessary.

July 5, 2013 | Unregistered CommenterEric Caron

This post about scaling site to 30,000, not about scaling PHP. PHP-FPM can process 350-400 max requests per second on one server

August 2, 2013 | Unregistered CommenterRoman

"Don't make connections to other servers in your PHP code.
Making connections to other servers blocks the server and slows down processing. Use the APC key/value store for data storage and Varnish for caching full pages."

Logic pages always need to connect to backend, eg, databases, memcache, or other backend services,
caching is a good ways to improve performance,

but how could you possible serve a page without a backend? many web application are far from been a simple page. hmmm I didn't get it. could anyone explain it?

August 11, 2013 | Unregistered Commenterreeze

@reeze: it could be static page!

January 2, 2014 | Unregistered Commentercanhnm

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>