IP hash uses the client's IP address to determine which server receives their request. The same IP always goes to the same server.
function ipHash(clientIp, servers):
hash = hashFunction(clientIp)
index = hash mod servers.length
return servers[index]
Time complexity is . Space is for the server list.
IP hash provides a form of session persistence without cookies. All requests from reach the same backend. But if servers are added or removed, the mapping changes and clients may shift to different servers.