Recall & Review
beginner
What is the purpose of using
ip_hash in nginx?The
ip_hash directive in nginx ensures that requests from the same client IP address are always sent to the same backend server. This helps keep user sessions consistent.Click to reveal answer
intermediate
How does
ip_hash differ from round-robin load balancing?Round-robin sends requests to backend servers in order, cycling through them.
ip_hash sends requests from the same IP to the same server, maintaining session persistence.Click to reveal answer
beginner
Show a simple nginx configuration snippet using
ip_hash.upstream backend {
ip_hash;
server backend1.example.com;
server backend2.example.com;
}
server {
location / {
proxy_pass http://backend;
}
}
Click to reveal answer
intermediate
What happens if a client IP changes when using
ip_hash?If the client IP changes, nginx may route the request to a different backend server, potentially breaking session persistence.
Click to reveal answer
intermediate
Can
ip_hash be used with SSL termination in nginx?Yes,
ip_hash works with SSL termination. The load balancer handles SSL and then uses ip_hash to route requests to backend servers.Click to reveal answer
What does the
ip_hash directive do in nginx?✗ Incorrect
ip_hash ensures session persistence by routing requests from the same client IP to the same backend server.
Which load balancing method does
ip_hash replace or complement?✗ Incorrect
ip_hash is an alternative to round-robin, focusing on session persistence rather than equal distribution.
What is a limitation of using
ip_hash for session persistence?✗ Incorrect
Client IP addresses can change, which may cause requests to be routed to different servers, breaking session persistence.
How do you enable
ip_hash in an nginx upstream block?✗ Incorrect
To enable ip_hash, add the line ip_hash; inside the upstream block.
If a user behind a proxy shares the same IP with others, what is a possible effect when using
ip_hash?✗ Incorrect
Since ip_hash uses client IP, users behind the same proxy IP will be routed to the same backend server.
Explain how
ip_hash helps maintain session persistence in nginx load balancing.Think about how nginx decides where to send requests from the same user.
You got /4 concepts.
Describe a scenario where using
ip_hash might cause problems and why.Consider what happens if the IP address is not stable or shared by many users.
You got /4 concepts.