Junior — Middle
Can you give an example of using load balancers in a system?
sobes.tech AI
Answer from AI
Load balancers are used to distribute incoming traffic across multiple servers or services to ensure high availability and scalability of the system. For example, in a web application, a load balancer can accept all HTTP requests and evenly distribute them among several application instances so that no single server is overwhelmed.
Use cases:
- In AWS cloud infrastructure, Elastic Load Balancer (ELB) automatically distributes traffic among EC2 instances.
- In Kubernetes, Ingress Controller or LoadBalancer type Service is used to distribute requests among pods.
Example configuration of Nginx as a load balancer:
http {
upstream backend {
server backend1.example.com;
server backend2.example.com;
}
server {
listen 80;
location / {
proxy_pass http://backend;
}
}
}