openresty / openresty/lua-nginx-module

ngx.exit() closes the connection. so benchmark tools with socket reuse (keep alive) do not work

Open
#2,082 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
11.8k
Forks
2.1k
Avg merge
6h 1m
Merged PRs (30d)
6

Description

Hi!
I perform a load testing for my web-server. I use wrk since I find it more suitable for loading up the network and the target web-server with a traffic, hence getting a more truthful results.

In several cases web-server's nginx location uses lua scripts. This scripts returns 403 (ngx.exit(ngx.HTTP_FORBIDDEN)).
In these cases wrk hangs, stopping sending requests after several seconds. The number of open sockets on web-server from a client becomes 0. And it looks that wrk is unable to reuse closed sockets.
Without lua scripting (just nginx' proxy_pass) return of 200 and 403 is possible without closing the socket so wrk or other benchmarks using keep alive continue to work.
Siege (or ab) benchmark works fine being configured to not to reuse sockets but rather close them after every request. Closing sockets after every request is slow and can lead to out of sockets problem on either client or server. You need to deal with TIME_WAIT, CLOSE_WAIT hanging sockets and so on. And I want my web-server to be keep-alive compliant anyway.

Is there an alternative way to finish current TCP-session without closing the network socket ?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported behavior with ngx.exit(ngx.HTTP_FORBIDDEN) and wrk using keep-alive connections. Then trace the ngx.exit path and its interaction with connection reuse; the payload names no source file or test. Done means the connection behavior is established and the supported outcome is documented or covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.