Fisrt access client distribution using hash

From: Karel Charousek <>
Date: Tue, 20 Mar 2007 22:15:10 +0100


we use pen to loadbalance and failover http application servers.

Detailed configuration:
- 2 target servers
- clients access only from subnet 192.168.0.*

I've investigated client distribution between both servers and I found
the clients accessing only first server.

I've looked into source code and I found following piece of code:
static void add_client(int downfd, struct sockaddr_in *cli_addr) {
if (hash) {
        index = cli % nservers;
        upfd = try_server(index, 0, cli);
        if (upfd != -1) goto Success;
where cli is cli_addr->sin_addr.s_addr which should be
On Linux x86 I ask for inet_aton for all IP addresses from subnet
192.168.0.* modulo nservers=2
and I always got 0.
That means all client from this subnet are pointed to server with index
0 ant nothing goes to server with index 1.

Is it possible to achieve equal client distribution in this environment
using pen?


Karel Charousek
Received on Tue Mar 20 2007 - 22:39:43 CET

This archive was generated by hypermail 2.2.0 : Tue Mar 20 2007 - 22:39:46 CET