Skip to main content

Posts

Showing posts with the label Scaling the system

Implementing load balancing with HAProxy in Node.js apps

What is a load balancer? Load balancers distribute incoming client requests to computing resources such as application servers and databases. In each case, the load balancer returns the response from the computing resource to the appropriate client. Why use a load balancer? Preventing requests from going to unhealthy servers Preventing overloading resources Helping to eliminate a single point of failure This introduction is enough to get started. For this tutorial, we are going to use  HAProxy  which is a free,  very  fast, and reliable solution offering  high availability ,  load balancing , and proxying for TCP and HTTP-based applications. We are not going to create a Node.js application here. For this tutorial let’s say you have a node.js application up and running on localhost:3000 When c l ients hits the server on localhost:3000 the server returns the appropriate response. Now let's say if we start sending a lot of requests to this single server, the...