I have develop a lua script to handle request. But it’s just about 800 QPS.(based on the ab test tool).
Finnaly, I found that I have to connect to remote server to get a query, and it should be keep-alive connection.
How can I use kee-alive connection in every request?
I’m assuming you would be using lua-resty-http
as your HTTP client.
You can use the set_keepalive()
API to reuse TCP connections.
You could refer to the http-log
plugin for details: https://github.com/Kong/kong/blob/next/kong/plugins/http-log/sender.lua#L84
If this answers your question, please mark this post as resolved. Thank you!
Thanks a lot.
But how can I debug with in luaJIT?
“resty.http” do not support debug standalone , but only within the the context of ngx_lua.
link
I have written the code, and I found that there are" not initialized" problem in my worker.
local httpc = http.new() -- here is no problem nor traceback.
httpc:set_timeout(5000) -- here is no problem nor traceback too.
ok, err = httpc:connect(host, port) -- here goes wrong, "not initialized" all the time
how can I fix this problem?
I’ve check all the code, still find nothing wrong with my code.
My code has somthing wrong, Your idea is helpful.
My RPS increase to 1300+, thanks!