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

Add option to control connection persistence (Keep-Alive) #197

Open
amichair opened this issue Mar 9, 2016 · 6 comments

Comments

Projects
None yet
5 participants
@amichair
Copy link

commented Mar 9, 2016

Thanks for the great tool!

It would be very useful to add an option (-k?) to control whether Keep-Alive is enabled or not, so that one can test the load in different scenarios of web server and network configurations.

Even better would be to specify then number of Keep-Alive requests per connection. For example, to better mimic the real load on a website, you could set this number to e.g. 10, such that on each client connection 10 requests are made and then the connection is closed, and the next request requires a new connection to be established. In this case a setting of 1 would be equivalent to no persistence (1 request per connection) and a setting of 0 might indicate unlimited persistence (which is the current and default behavior, if I understand the thin documentation correctly).

@Snuggert

This comment has been minimized.

Copy link

commented Apr 26, 2016

In HTTP/1.1 a connection is always assumed to be keep-alive.
To close a connection after every request you can use the --header "Connection: Close" option.
For the even better part you could specify a per request header using a lua script.

@amichair

This comment has been minimized.

Copy link
Author

commented Apr 26, 2016

I realize it can be done with a script... but that is much more work (especially to non-developers or the majority of developers, who are not fluent in Lua). My point is that this seems to me like very common and useful functionality for testing real-life scenarios on any HTTP server the will be accessed by real-world browsers, which is most of them. For something very useful and common, it's worth adding a built-in command line option rather than having many people re-implementing the same functionality themselves in scripts... that's mho anyway :-)

@nono nono referenced this issue Jul 5, 2016

Closed

Things to improve #5

@amsharma

This comment has been minimized.

Copy link

commented Aug 22, 2016

You can also use the -H "Connection: Close" on the command line, no need to put it in a lua script.

@mafjmafj

This comment has been minimized.

Copy link

commented Aug 14, 2017

Note -H "Connection: Close" make serves close the connection. Which is quite different from clients closing them.
Whether client or server closes a connection - it changes quite a lot resource use and connection clean up responsibilities - different aspects of TCP handling.
When server is made to close connections the OS keeps connections for minutes in TIME_WAIT state.
This is quite heavy burden on the server.

@amichair

This comment has been minimized.

Copy link
Author

commented Apr 3, 2019

Got a few thumb-ups up there in the past couple of years... would you reconsider implementing the -k command line argument suggestion? I think that can solve all the pipeline-related scenarios pretty elegantly.

@noahgibbs

This comment has been minimized.

Copy link

commented Apr 18, 2019

I assume that to do this with a Lua script, you would disconnect the connection (and reopen?) in the "response" global Lua function. However, there doesn't seem to be any kind of disconnect or reconnect in the Lua API. So I don't think this can be done from Lua.

You can specify the header, of course, and then you're asking the server to do it for you. Similar, but not quite the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.