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.