Ketama hash support
Closed this issue · 1 comments
When upstream is defined with hash consistent, upstream server will be added via HTTP API, but will not receive traffic.
Example config:
upstream test {
hash $arg_hash consistent;
keepalive 16;
zone test_upstream 10m;
server 10.1.5.250 weight=100;
}
@Perlovka
It is not possible to implement because internal structure for hased upstream declared in ngx_http_upstream_hash_module.c. This is an internal feature of the hash upstream module.
In custom upstream modules we have access only to ngx_http_upstream_rr_peer_t.
But for hash nginx declare separate internal structure:
typedef struct {
/* the round robin data must be first */
ngx_http_upstream_rr_peer_data_t rrp;
ngx_http_upstream_hash_srv_conf_t *conf;
ngx_str_t key;
ngx_uint_t tries;
ngx_uint_t rehash;
uint32_t hash;
ngx_event_get_peer_pt get_rr_peer;
} ngx_http_upstream_hash_peer_data_t;
We don't have access to this structure.
More: dynamicaly add/remove peers from hashed upstream corrupts the memory.
You may write custom balancer with lua-nginx-module by balancer_by_lua_block.