Загрузка...

These are 4 algorithms you must know if you want to distribute load wisely. #systemdesign

The 3 algorithms I discussed — Round Robin, Weighted Round Robin, and Least Connections — all work best for stateless requests. The load balancer does not care which server the user was on before. Every request is independent.
But what about stateful requests?
When your app stores cart data, login sessions, or user state locally on a server, you need the same user to always hit the same server. That is where IP Hash comes in.
How it works: The load balancer takes the user's IP address, runs a hash function on it, and maps it to a specific server. Same IP, same server. Every time.
Real scenario: User adds 3 items to cart on Server 2. Without IP Hash, the next request could land on Server 3. Cart is empty. User is confused. With IP Hash, every request from that user hits Server 2. Cart stays intact.
The downsides:
* If Server 2 goes down, all users mapped to it get rehashed and redistributed. Temporary session loss.
* If 500 employees in a corporate office share a similar IP range, one server gets hammered while others sit idle.
* Users behind VPNs or proxies share the same IP, creating the same hotspot problem.
When to use: Session-heavy apps where you cannot externalize state to Redis or a shared database. If you can use Redis for sessions, Least Connections is usually the better choice.
Quick cheat sheet: Round Robin — simple, equal, stateless Weighted Round Robin — matches server capacity, stateless Least Connections — picks least busy server, stateless IP Hash — session stickiness, stateful
Save this for your next system design round.

Видео These are 4 algorithms you must know if you want to distribute load wisely. #systemdesign канала Amit Vikram Awasthi
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять