
📈 The Need for Scaling - Vertical vs Horizontal
📈 The Need for Scaling - Vertical vs Horizontal 관련
Imagine your app is growing. At first, it’s just a few users. Then a few hundred. Then thousands are logging in, placing orders, chatting, uploading photos - all at once 😮
Suddenly, your server (VM) is under pressure. It’s like trying to pour a flood through a straw.
So, What Do You Do When One Server Isn’t Enough?
This is where scaling comes in - the art of upgrading your app’s infrastructure to keep up with traffic.
There are two main ways to scale:
🧱 Option 1: Vertical Scaling (aka Scaling Up)
You take your existing VM and give it more power:
- Add more CPUs 🧠
- Increase RAM 🧵
- Add faster disks ⚡
Think of it like upgrading from a regular car to a sports car. It’s the same vehicle, just faster and stronger.
- Simple to do
- No major changes to your app setup
- There’s a limit to how much you can upgrade
- Still a single point of failure: if the VM crashes, everything goes down 😬
🧩 Option 2: Horizontal Scaling (aka Scaling Out)
Instead of boosting one server, you add more servers - multiple VMs running copies of your app.
Now:
- Users can be distributed across all these VMs
- If one goes down, others keep serving traffic
- You can dynamically add or remove VMs based on traffic
It’s like opening more checkout counters in a busy supermarket 🛒
- The load is evenly distributed. For example, if one server previously handled 100% of the traffic, adding two more servers would result in the traffic being split into approximately 33% to 34% for each server.
- Improves both performance and reliability
- You can scale based on real-time demand, that is traffic inflow
- Needs something to split traffic between VMs - Load Balancers
- More expensive. You end up paying the original amount for 1 VM (for example $30) for the number of VMs you provide - if you provide 3 VMs at $30 each, you end up paying $90 at the end of the month
Quick Real-World Example
Let’s say you’ve launched an e-commerce site for sneakers 👟 Traffic spikes during a big sale? Your vertical scaling (bigger VM) might choke.
But with horizontal scaling:
- You spin up 5 VMs across different regions
- Traffic is shared between them
- If one VM slows down, others handle the load
So, remember 👇🏾
Scaling Type | Description | Pros | Cons |
---|---|---|---|
🧱 Vertical Scaling | Make 1 VM more powerful (adding more CPU power, SSD, RAM, bandwidth, and so on) | Easy setup, fewer changes | Hardware limits, 1 point of failure - If that 1 server/VM goes down, so does your app |
🧩 Horizontal Scaling | Add more VMs to handle traffic | Flexible, reliable | Needs traffic distribution logic (Load Balancer). Usually more expensive (the price of 1 VM times the number of VMs) |