System Design ( Day - 11 )

Manoj KumarManoj Kumar
2 min read

HeartBeats in Microservices, Rate limiting

We want our servers available all the time, we need all the services up all the me, because we take care of the other things like efficiency, Reliability, consistency, but for doing this the each services has to be available, for that we need to use heart beat for the servers.

HeartBeats: Its like let’s say we have a Heart beat service running and for that heartbeat service we have 4 servers connected to that, for every 5 or 10 seconds the heart beat service has to send the message to the servers that, Hey are you alive?, if the server alive then it’ll reply, and no problem, but what if one server doesn’t reply then the heart beat server thinks that server as critical, it sends another time the same message, if it replies then its ok no problem, but if heart beat server doesn’t get any reply then that server will be requested for the restart or send that server to the maintenance team, the requests are mapped to the another servers, what’s the problem here is we need to add more calls but with this we can have more consistent system that is build out there,

RateLimiting

Let’s say we have 4 servers each server will server 100 requests, 0 - 100 requests for Server1, 101- 200 for server2, 201 - 300 for server 3 and 301 - 400 for server4, but server 1 failed, then the requests in the server 1 will distribute to remaining servers, only it can handle 100 requests, so with this distributed requests , server 3 fails then that request also distributed, so on and so fourth, by this all the servers are destroyed, this is not good at all. this is called cascading failure.

for this Problem, we have to limit the requests for each servers for some requests, by this way we can reduce the chances of server failures, by avoiding some users, if i don’t want to loose any users means i have to check the load or predict the load of the users and add more servers in the seasons like sales, or something else. its called pre-Scaling or We can do auto-scale, it actually do like if the users are increasing then it’ll add more servers, if users are decreased then the un-used servers will be deleted or it’ll be removed to save the cost.

0
Subscribe to my newsletter

Read articles from Manoj Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Manoj Kumar
Manoj Kumar