Hi @matsumotory, I've been spending some time benchmarking OpenResty's lua-resty-redis library vs. mruby-redis and have come across a specific and noticeable difference with one particular setting. The keep alive connection pool.
First, the data: when benchmarking a very simple single get call:
Not bad. Let's look at Lua with a single connection (this is what I assume we're doing in mruby with the above code):
local ok, redis = pcall(require, "resty.redis")
local redis_client = redis:new()
local ok, error = redis_client:connect("127.0.0.1", 6379)
local key_lookup, error = redis_client:get("test")
if not key_lookup then
ngx.log(ngx.ERR, error)
end
local ok, error = redis_client:set_keepalive(60000, 1)
ngx.say(key_lookup)
Now let's increase the Lua connection pool to 100:
local ok, redis = pcall(require, "resty.redis")
local redis_client = redis:new()
local ok, error = redis_client:connect("127.0.0.1", 6379)
local key_lookup, error = redis_client:get("test")
if not key_lookup then
ngx.log(ngx.ERR, error)
end
local ok, error = redis_client:set_keepalive(60000, 100)
ngx.say(key_lookup)
Hi @matsumotory, I've been spending some time benchmarking OpenResty's
lua-resty-redis
library vs.mruby-redis
and have come across a specific and noticeable difference with one particular setting. The keep alive connection pool.First, the data: when benchmarking a very simple single get call:
Yields the following results:
Not bad. Let's look at Lua with a single connection (this is what I assume we're doing in mruby with the above code):
Results:
Ok, so far mruby is handling its business.
Now let's increase the Lua connection pool to 100:
And check the results:
Wowsa, that's quite the difference! Almost 25,000 rps.
So I have some obvious questions.
mruby-redis
?Thanks for taking the time to read through this, and if I'm doing something obviously wrong, make sure to let me know. 😄