浅谈ngx.exit,ngx.eof,ngx.timer.at

简介:

最近要快速搭建日志采集服务端,想到了基于openresty。这里主要介绍下ngx.exit,ngx.eof,ngx.timer.at这三者的区别。

1.ngx.exit 立即中断当前http请求,后续lua代码将不会再执行,底层socket通道还存在,只要没超过保活时间,如果用了proxypass做子请求,不影响。


2.ngx.eof 立即中断当前http请求,后续的lua代码将继续执行,底层socket通道也立即断开,如果用了proxypass做子请求,子请求也会断开。


3.ngx.timer.at 这个是nginx提供的轻线程,主要做后台任务执行用,一般和ngx.exit配合使用。


下面是自己搭建的openresty性能压测的情况 分别对应上面三种写法,压测工具是apachebench,压测环境是4核4g虚拟机

3900/1并发用户数,6000/20000并发用户数)
3600/1并发用户数,9300/20000并发用户数

4700/1并发用户数,9300/20000并发用户数
目录
相关文章
|
8天前
|
应用服务中间件 nginx
ngx_http_fastdfs_process_init pid=44362023/05/13 09:31:23 [alert] 2964#0: worker process 4436 exite
ngx_http_fastdfs_process_init pid=44362023/05/13 09:31:23 [alert] 2964#0: worker process 4436 exite
8 0
|
8天前
|
应用服务中间件 nginx
Nginx源码阅读:共享内存ngx_shm_t和它的组织方式ngx_shm_zone_t、ngx_list_t
Nginx源码阅读:共享内存ngx_shm_t和它的组织方式ngx_shm_zone_t、ngx_list_t
26 0
|
8天前
|
应用服务中间件 nginx
nginx日志模块 ngx_http_log_module
nginx日志模块 ngx_http_log_module
|
7月前
|
应用服务中间件 nginx
【Nginx异常】[error] 4236#29900: OpenEvent(“Global\ngx_reload_27128“) failed (5: Access is denied)
【Nginx异常】[error] 4236#29900: OpenEvent(“Global\ngx_reload_27128“) failed (5: Access is denied)
206 0
|
10月前
|
JSON 应用服务中间件 测试技术
【2022】Nginx使用ngx_http_log_module模块定义日志
【2022】Nginx使用ngx_http_log_module模块定义日志
102 0
|
Unix 应用服务中间件 nginx
安装nginx:src/os/unix/ngx_user.c:26:7: error: ‘struct crypt_data’ has no member named ‘curren
安装nginx:src/os/unix/ngx_user.c:26:7: error: ‘struct crypt_data’ has no member named ‘curren
816 0
安装nginx:src/os/unix/ngx_user.c:26:7: error: ‘struct crypt_data’ has no member named ‘curren
|
应用服务中间件 nginx
[error] OpenEvent(“Global\ngx_reload_11812“) failed (2: The system cannot find the file specified
[error] OpenEvent(“Global\ngx_reload_11812“) failed (2: The system cannot find the file specified
|
存储 自然语言处理 网络协议
手把手教你Nginx常用模块详解之ngx_http_limit_conn_module(五)
手把手教你Nginx常用模块详解之ngx_http_limit_conn_module(五)
110 0
|
应用服务中间件 nginx C语言
nginx 编译出现的问题ngx_murmurhash.o failed
nginx 编译出现的问题ngx_murmurhash.o failed
2712 0
|
应用服务中间件 nginx

热门文章

最新文章