scalability - How to scale PHP -


i'm creating new web application in php , i'd create in way scales on time.

what should or shouldn't do? know should cache, should cache , how? else can website remain loading rapidly?

note: wasn't written me, snorkel yc news

here's short list:

  1. cache output @ edges: use varnish or other reverse proxy cache.
  2. cache byte code: use apc or xcache php opcode cache.
  3. cache , minimize database i/o: reduce database touches using memcached, redis, file caches, , application-level caches (ie. global vars)
  4. do event logging in local files, not database: make write operations simple , fast possible, data not needed in realtime can written plain old file , processed later.
  5. use cdn, delivering static assets
  6. server tuning: apache, mysql, , linux have lots of settings affect performance, timeout settings ought turned down.
  7. identify bottlenecks: @ system level use tools such strace, top, iostat, vmstat, , query logging see layer using time , resources
  8. load testing: dos yourself. stress test stack find bottlenecks , tune them out
  9. remove unused modules: each component in stack unload default modules not needed deliver service.
  10. don't use orms , other dummy abstractions: take off training wheels , write own queries.
  11. make entry pages fast, simple, , cacheable. nobody reading silly news feed in bottom corner of front page , it's killing database, take out.

most of time php slows down because each php process blocked waiting i/o other layer, either slow disk, or overloaded database, or hung memcached process, or slow rest api call 3rd party service ... strace'ing live php process show waiting ... in short, blocking i/o slows down everything. key going faster is:

- keep simple

- cache as possible in local memory

- few blocking i/o operations possible per request


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -