-
Notifications
You must be signed in to change notification settings - Fork 6
Home
qiaodandedidi edited this page Sep 30, 2014
·
6 revisions
Welcome to the ngx_lua_consistent wiki!
local servers = {192.168.0.3, 192.168.3.1, 192.168.0.2};
local consistent = require 'consistent';
consistent.add_server(servers);
local key = 'http://baidu.com/haha';
local ip = consistent.get_upstream(key); --one of the servers
local consistent = require 'resty.consistent';
consistent.add_server({'127.0.0.1', '127.0.0.2'});
local a,b = 1,1;
for i=1, 10000 do
local ser = consistent.get_upstream(math.random());
if ser == '127.0.0.1' then
a = a+1;
else
b = b+1;
end
end
ngx.say(a,','b); --5404,4598