openresty / openresty/lua-resty-redis

redis set_keepalive doesn't work

Open
#268 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
2k
Forks
447
Avg merge
2h 24m
Merged PRs (30d)
3

Description

I am writing a test to test the performance of reids. The following is my test code.
I used 2000 threads to test,and listen to the tcp connection of redis.
That connection pool doesn't seem to work very well, is it my code problem?

http {
    server {
        listen 80;

        location /redis {
            content_by_lua_block {
                local resty_redis = require "resty.redis"
                local redis = resty_redis:new()

                local ok, err = redis:connect("127.0.0.1", 6379)
                if not ok then
                    ngx.say("Failed to connect to Redis: ", err)
                    return
                end

                local res, err = redis:auth("r-xxxxx")
                if not res then
                    ngx.say("Failed to authenticate with Redis: ", err)
                    return
                end

                local key = "test"
                local value, err = redis:get(key)
                if not value then
                    ngx.say("Failed to get key from Redis: ", err)
                else
                    ngx.say("Value of key ", key, ": ", value)
                end

                redis:set_keepalive(100000, 1000)
            }
        }
    }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the resty.redis:new(), connect(), auth(), and set_keepalive() entry points, then run the supplied configuration under the reported 2000-thread Redis load and inspect connection reuse. Done means the pooling behavior is explained and, if it is a library defect, the fix is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, redis
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.