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:
- cache output @ edges: use
varnishor other reverse proxy cache. - cache byte code: use
apcorxcachephp opcode cache. - cache , minimize database i/o: reduce database touches using
memcached,redis, file caches, , application-level caches (ie. global vars) - 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.
- use cdn, delivering static assets
- server tuning:
apache,mysql, ,linuxhave lots of settings affect performance, timeout settings ought turned down. - identify bottlenecks: @ system level use tools such
strace,top,iostat,vmstat, , query logging see layer using time , resources - load testing: dos yourself. stress test stack find bottlenecks , tune them out
- remove unused modules: each component in stack unload default modules not needed deliver service.
- don't use orms , other dummy abstractions: take off training wheels , write own queries.
- 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:
Comments
Post a Comment