Skip to content

redis set_keepalive doesn't work #268

Open
@ebony0319

Description

@ebony0319

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)
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions