jiangdongzi opened a new issue, #11739:
URL: https://github.com/apache/apisix/issues/11739
### Current Behavior
http {
upstream backend_servers {
server 172.27.255.37:81;
keepalive 16;
}
server {
listen 9085;
server_name localhost;
access_by_lua_block {
apisix.http_access_phase()
}
location / {
proxy_pass http://backend_servers; # 或者使用 proxy_pass
http://backend_servers$request_uri;
proxy_set_header Connection "";
proxy_http_version 1.1;
}
}
function _M.http_access_phase()
local ngx_ctx = ngx.ctx
if not verify_tls_client(ngx_ctx.api_ctx) then
return core.response.exit(400)
end
-- always fetch table from the table pool, we don't need a reused api_ctx
local api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
ngx_ctx.api_ctx = api_ctx
core.ctx.set_vars_meta(api_ctx)
if true then return end
These code alone decrease qps 13%
### Expected Behavior
_No response_
### Error Logs
_No response_
### Steps to Reproduce
just add the conf
upstream backend_servers {
server 172.27.255.37:81;
keepalive 16;
}
server {
listen 9085;
server_name localhost;
access_by_lua_block {
apisix.http_access_phase()
}
location / {
proxy_pass http://backend_servers; # 或者使用 proxy_pass
http://backend_servers$request_uri;
proxy_set_header Connection "";
proxy_http_version 1.1;
}
}
then change http_access_phase
function _M.http_access_phase()
local ngx_ctx = ngx.ctx
if not verify_tls_client(ngx_ctx.api_ctx) then
return core.response.exit(400)
end
-- always fetch table from the table pool, we don't need a reused api_ctx
local api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
ngx_ctx.api_ctx = api_ctx
core.ctx.set_vars_meta(api_ctx)
if true then return end
and wrk test get qps: 29591.64
ant then move `if true then return end` just in the entrance of the func
function _M.http_access_phase()
if true then return end
local ngx_ctx = ngx.ctx
if not verify_tls_client(ngx_ctx.api_ctx) then
return core.response.exit(400)
end
-- always fetch table from the table pool, we don't need a reused api_ctx
local api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
ngx_ctx.api_ctx = api_ctx
core.ctx.set_vars_meta(api_ctx)
and wrk test get qps 34175.09
### Environment
- APISIX version (run `apisix version`): any version
- Operating system (run `uname -a`):
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
- etcd version, if relevant (run `curl
http://127.0.0.1:9090/v1/server_info`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]