Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: I test apisix performance is significantly poor compared with nginx. Why, Below is my conf #11739

Open
jiangdongzi opened this issue Nov 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jiangdongzi
Copy link

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):
@dosubot dosubot bot added the bug Something isn't working label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant