luasocket icon indicating copy to clipboard operation
luasocket copied to clipboard

Are there req/s limits on http.request?

Open dr3n83 opened this issue 2 years ago • 4 comments

In tests using http.request I had problems exceeding 1k req/s. Below that, the response time is around 1ms, when it gets to 1k, my response time goes to 500ms to 1s for each request. Has anyone had this kind of problem? I didn't find anything about it here.

dr3n83 avatar Mar 23 '22 02:03 dr3n83

there can be a lot of different reasons for this to happen... resource shortage (memory, sockets/fds), network, server side latency, etc.

Tieske avatar Mar 23 '22 11:03 Tieske

Thanks a lot for the quick response.

All the points mentioned were often analyzed in detail. Both via monitoring tool like Netdata and commands like strace, mpstat and etc. There is no resource exhaustion, ringbuffer overflow or filedescriptors overflow. Sysctl is fine tuned.

I use luasocket inside a lua script called on my PowerDNS server. I validated in many ways and everything pointed to the http.request function I use luasocket to. When I have a stream above 1k of reqs/s, I have horrible degradation in response time with http.request.

Could you help me in a way to be able to debug this better inside luasocket?

dr3n83 avatar Mar 24 '22 03:03 dr3n83

Unfortunately this is beyond my knowledge of LuaSocket, maybe someone else knows...

Tieske avatar Mar 24 '22 12:03 Tieske

It may be an effect of the Nagle's algorithm that seems not to be disabled in http.lua. Something like h.try(c:setoption('tcp-nodelay', true) in http.lua (function _M.open) may help in this very specific case but may not be desirable for normal HTTP usage.

CDSoft avatar Mar 24 '22 19:03 CDSoft