doujiang24 / lua-resty-kafka

Lua kafka client driver for the Openresty based on the cosocket API
BSD 3-Clause "New" or "Revised" License
801 stars 274 forks source link

producer.lua:284: _flush_buffer(): failed to create timer at _flush_buffer, err: too many pending timers #66

Closed sstong123 closed 6 years ago

sstong123 commented 6 years ago

local bp = producer:new(broker_list, { producer_type = "async" }); local ok, err = bp:send(topicName, key, message)

When I use a performance tool to mock about 2000 concurrent users to call the above code,all the messages are saved in kafka server(as expected),but I get the errors in nginx error.log as blow,why this happened?

2018/04/24 10:15:15 [error] 6934#0: *429631 [lua] producer.lua:284: _flush_buffer(): failed to create timer at _flush_buffer, err: too many pending timers, client: 10.150.50.235, server: , request: "POST /saveKafkaMsg HTTP/1.0", host: "10.150.50.234"

sstong123 commented 6 years ago

Is there any potential issue under high concurrency?

doujiang24 commented 6 years ago

@sstong123 you can simply increase the lua_max_pending_timers. https://github.com/openresty/lua-nginx-module/#lua_max_pending_timers

sstong123 commented 6 years ago

add lua_max_pending_timers 1024 in nginx.conf file?

doujiang24 commented 6 years ago

@sstong123 nope, 1024 is the default value, you should use 2048 or 4096 for your case. please see the doc carefully next time.

sstong123 commented 6 years ago

I mean shoud I add the lua_max_pending_timers value in nginx.conf file?(not about the value)

doujiang24 commented 6 years ago

@sstong123 yes.

sstong123 commented 6 years ago

I got the below error message when my code like location = /test {lua_max_pending_timers 2048....} or server{lua_max_pending_timers 2048...}

[emerg] 8420#14252: "lua_max_pending_timers" directive is not allowed here in nginx.conf:125

Is 'lua_max_pending_timers 'directive under 'local 'or 'server' tag? or need import something ?

xiaooloong commented 6 years ago

lua_max_pending_timers

syntax: lua_max_pending_timers <count>

default: lua_max_pending_timers 1024

context: http

http {
    lua_max_pending_timers 2048;
    server {
         #...
    }
}