Interview question
What is the difference between horizontal and vertical scaling for PHP applications? PHP applications के लिए horizontal और vertical scaling में क्या अंतर है?
Answer
| Scaling type | How it works | Trade-offs |
|---|---|---|
| Vertical scaling | Add more CPU/RAM to a single server | Simple but has a hardware ceiling; single point of failure |
| Horizontal scaling | Add more servers behind a load balancer | More complex (needs shared session/cache) but scales further and improves redundancy |
Horizontal scaling requirements for PHP:
Sessions moved to Redis/database (not local files) → Uploaded files stored in shared storage (S3, not local disk) → Load balancer distributes requests across app servers → Database often needs read replicas
Sessions moved to Redis/database (not local files) → Uploaded files stored in shared storage (S3, not local disk) → Load balancer distributes requests across app servers → Database often needs read replicas
Most production PHP setups use horizontal scaling for the application layer combined with vertical scaling on the database layer.
| Scaling type | कैसे काम करता है | Trade-offs |
|---|---|---|
| Vertical scaling | एक server में CPU/RAM बढ़ाना | Simple पर hardware limit है |
| Horizontal scaling | Load balancer के पीछे कई servers | Complex पर ज़्यादा scale होता है |
Horizontal scaling के लिए ज़रूरी:
Sessions Redis में (local file नहीं) → Files shared storage में → Load balancer requests बांटता है
Sessions Redis में (local file नहीं) → Files shared storage में → Load balancer requests बांटता है
Was this answer clear?