|2. Scalability — Scale करायला शिका
Chapter 2System Design~1 min read

Scalability — Scale करायला शिका

Millions of Users Handle करणे

Scalability म्हणजे system चा load वाढला तरी performance maintain करण्याची क्षमता. तुमची website 100 users साठी ठीक आहे पण 1 million users आले तर crash होते का? — हा scalability चा प्रश्न आहे.

Vertical Scaling (Scale Up)

एकाच server ला upgrade करणे — जास्त RAM, जास्त CPU, faster SSD. सोपं आहे पण एक मर्यादा आहे — एका machine ला किती upgrade करणार? आणि single point of failure आहे.

Vertical Scaling

text
Before: 1 server — 4 CPU, 16 GB RAM
After:  1 server — 32 CPU, 256 GB RAM

✅ Simple — code बदलावं लागत नाही
✅ No distributed system complexity
❌ Hardware limit आहे — इतकंच upgrade होतं
❌ Expensive
❌ Single Point of Failure — server गेला तर सगळं down

Horizontal Scaling (Scale Out)

एकाच server ला upgrade न करता जास्त servers add करणे. Load Balancer मध्ये distribute होतो. Amazon, Google हेच करतात.

Horizontal Scaling

text
Before: 1 server (4 CPU, 16 GB RAM)
After:  10 servers (4 CPU, 16 GB RAM each)
        + Load Balancer (traffic distribute करतो)

✅ Theoretically unlimited scale
✅ No single point of failure
✅ Cost-effective (commodity hardware)
❌ Distributed system complexity
❌ Stateless servers हवेत (session management tricky)

Stateless vs Stateful Servers

  • Stateful server: user session त्याच server वर store करतो — horizontal scaling कठीण
  • Stateless server: state कुठेच store नाही (Redis/DB मध्ये) — horizontal scaling सोपं
  • Solution: Sessions Redis मध्ये store करा — कोणताही server request handle करू शकतो
📌

Netflix च्या peak time ला (Sunday रात्री) AWS वर automatically नवीन servers add होतात आणि रात्री कमी traffic असताना remove होतात. हे Auto Scaling आहे.

Key Points — लक्षात ठेवा

  • Vertical = बड्या machine, Horizontal = जास्त machines
  • Production systems: Horizontal scaling prefer करतात
  • Stateless servers = horizontal scaling सोपं
  • Auto Scaling — load नुसार servers automatically add/remove
  • Database scaling वेगळी challenge आहे (sharding)
0/11 chapters पूर्ण