asukaliy1

Results 4 comments of asukaliy1

![image](https://user-images.githubusercontent.com/26673975/51237035-95382780-19ae-11e9-9353-c3859764b385.png) 使用jmeter测试的,4核8G,1000并发下,平均63ms:`jmeter -n -t gateway.jmx -l test.result -e -o ./weblog/` ```lua local config = { name = "testCluster", --rediscluster name serv_list = { --redis cluster node list(host and port), {...

> @asukaliy1 你是把他放到init_worker_lua这个阶段处理就初始化了连接池吗,还是怎么做的,请指教 不管你写哪儿,只会初始化一次的,后来的连接处理时都是引用 ``` 1、please compile and generate redis_slot.so from redis_slot.c (can done by gcc) 2、please add redis_slot.so and rediscluster.lua at lualib, Also please add library:lua-resty-redis and lua-resty-lock nginx.conf...

rediscluster是个模块(table),require之后,缓存在 package.loaded 这个全局表中(这个表是注册在 Lua registry 里,而 Lua registry 是 VM 级别唯一的,共享的); 每个nginx worker(工作进程)创建一个Lua VM,worker内所有协程共享VM; 因此你之后的require之后,其实只是获取一个引用; 具体可以参考[并发请求的变量问题](https://groups.google.com/forum/#!topic/openresty/3ylMdtvUJqg)

而且rediscluster底层依然是使用ngx_lua's cosocket API的,而tcpsock:connect是不支持在init_worker_lua环境中使用的~ [ngx.socket.tcp说明](https://github.com/openresty/lua-nginx-module#ngxsockettcp)