You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Puts the current Redis connection immediately into the ngx_lua cosocket connection pool.
@@ -348,8 +366,8 @@ Reading a reply from the redis server. This method is mostly useful for the [Red
348
366
localred=redis:new()
349
367
localred2=redis:new()
350
368
351
-
red:set_timeout(1000) -- 1 sec
352
-
red2:set_timeout(1000) -- 1 sec
369
+
red:set_timeouts(1000, 1000, 1000) -- 1 sec
370
+
red2:set_timeouts(1000, 1000, 1000) -- 1 sec
353
371
354
372
localok, err=red:connect("127.0.0.1", 6379)
355
373
ifnotokthen
@@ -417,7 +435,7 @@ Adds new redis commands to the `resty.redis` class. Here is an example:
417
435
418
436
localred=redis:new()
419
437
420
-
red:set_timeout(1000) -- 1 sec
438
+
red:set_timeouts(1000, 1000, 1000) -- 1 sec
421
439
422
440
localok, err=red:connect("127.0.0.1", 6379)
423
441
ifnotokthen
@@ -450,7 +468,7 @@ commands like `GET` and `SET`. So one can just invoke the `auth` method on your
450
468
localredis=require"resty.redis"
451
469
localred=redis:new()
452
470
453
-
red:set_timeout(1000) -- 1 sec
471
+
red:set_timeouts(1000, 1000, 1000) -- 1 sec
454
472
455
473
localok, err=red:connect("127.0.0.1", 6379)
456
474
ifnotokthen
@@ -487,7 +505,7 @@ This library supports the [Redis transactions](http://redis.io/topics/transactio
487
505
localredis=require"resty.redis"
488
506
localred=redis:new()
489
507
490
-
red:set_timeout(1000) -- 1 sec
508
+
red:set_timeouts(1000, 1000, 1000) -- 1 sec
491
509
492
510
localok, err=red:connect("127.0.0.1", 6379)
493
511
ifnotokthen
@@ -574,7 +592,7 @@ Check List for Issues
574
592
575
593
1. Ensure you configure the connection pool size properly in the [set_keepalive](#set_keepalive) . Basically if your NGINX handle `n` concurrent requests and your NGINX has `m` workers, then the connection pool size should be configured as `n/m`. For example, if your NGINX usually handles 1000 concurrent requests and you have 10 NGINX workers, then the connection pool size should be 100.
576
594
2. Ensure the backlog setting on the Redis side is large enough. For Redis 2.8+, you can directly tune the `tcp-backlog` parameter in the `redis.conf` file (and also tune the kernel parameter `SOMAXCONN` accordingly at least on Linux). You may also want to tune the `maxclients` parameter in `redis.conf`.
577
-
3. Ensure you are not using too short timeout setting in the [set_timeout](#set_timeout)method. If you have to, try redoing the operation upon timeout and turning off [automatic error logging](#automatic-error-logging) (because you are already doing proper error handling in your own Lua code).
595
+
3. Ensure you are not using too short timeout setting in the [set_timeout](#set_timeout)or [set_timeouts](#set_timeouts) methods. If you have to, try redoing the operation upon timeout and turning off [automatic error logging](#automatic-error-logging) (because you are already doing proper error handling in your own Lua code).
578
596
4. If your NGINX worker processes' CPU usage is very high under load, then the NGINX event loop might be blocked by the CPU computation too much. Try sampling a [C-land on-CPU Flame Graph](https://github.com/agentzh/nginx-systemtap-toolkit#sample-bt) and [Lua-land on-CPU Flame Graph](https://github.com/agentzh/stapxx#ngx-lj-lua-stacks) for a typical NGINX worker process. You can optimize the CPU-bound things according to these Flame Graphs.
579
597
5. If your NGINX worker processes' CPU usage is very low under load, then the NGINX event loop might be blocked by some blocking system calls (like file IO system calls). You can confirm the issue by running the [epoll-loop-blocking-distr](https://github.com/agentzh/stapxx#epoll-loop-blocking-distr) tool against a typical NGINX worker process. If it is indeed the case, then you can further sample a [C-land off-CPU Flame Graph](https://github.com/agentzh/nginx-systemtap-toolkit#sample-bt-off-cpu) for a NGINX worker process to analyze the actual blockers.
580
598
6. If your `redis-server` process is running near 100% CPU usage, then you should consider scale your Redis backend by multiple nodes or use the [C-land on-CPU Flame Graph tool](https://github.com/agentzh/nginx-systemtap-toolkit#sample-bt) to analyze the internal bottlenecks within the Redis server process.
0 commit comments