Professional Documents
Culture Documents
Scale Perf Best Practices
Scale Perf Best Practices
Practices
2
Why are Scalability and
Performance Important?
No hope of growth otherwise.
Scalability means you can handle service
commitments of the future.
Performance means you can handle the
service commitments of today.
Both act symbiotically to mean cost-
efficient growth.
3
Why PHP?
4
When to Start
5
Knowing When to Stop
6
No Fast = True
7
General Best Practices
8
Scalability Best Practices
1. Decouple.
2. Cache.
3. Federate.
4. Replicate.
5. Avoid straining hard-to-scale
resources.
9
Performance Best Practices
10
1. Profiling
11
2. Dev-Ops Cooperation
12
3. Test on Production(-ish) Data
13
4. Track and Trend
14
Access log timings
15
5. When you assume
16
6. Decouple
17
Example:
Static versus dynamic content
Apache + PHP is fast for dynamic content
Waste of resources to serve static
content from here: images, CSS,
JavaScript
Move static content to a separate faster
solution for static content e.g. lighttpd
on a separate box -> on a
geographically distributed CDN
18
Example: Session data
19
7. Cache
20
Caching examples
22
9. Replicate
23
Problems
26
10. Avoid Straining Hard-to-Scale
Resources
Some resources are inherently hard to scale
Uncacheable data
Data with a very high read+write rate
Non-federatable data
Data in a black-box
Be aware of these limitations and be extra
careful with these resources.
Try and poke holes in the assumptions about
why the data is hard to manage.
27
11. Compiler Cache
29
Managing external data and
services
Cache it (beware of AUPs for APIs)
Batch writes
30
Query tuning
31
Indexing problems
32
Schema design (MySQL)
33
Queries
34
13. Be Lazy
35
14. Dont Outsmart Yourself
36
15. Caching
37
Thanks!
38