Hello!
On Thu, May 30, 2013 at 6:45 AM, Rohit Yadav wrote:
> With a noncurrent load test of total 1M requests, using the library a
> producer (in /example/) was able to publish all the messages to the broker
> without any errors. But in case of concurrent connections, I frequently got
> timeout errors or writing to closed socket errors.
>
When timeout errors happen, you should handle the error in Lua and
prevent further writing operations into the socket (because the
timed-out socket is closed automatically by ngx_lua).
To trace the causes of the timeout errors, you can use the
ngx-accept-queue and ngx-recv-queue tools in my Nginx Systemtap
Toolkit if you're on Linux:
https://github.com/agentzh/nginx-systemtap-toolkit
The dropwatch tool from RedHat can serve as a good addition as well.
Other tools in my Nginx Systemtap Toolkit like ngx-sample-bt and
ngx-sample-bt-off-cpu for rendering various kinds of Flame Graphs can
be very useful in spotting bottlenecks and other issues.
Use the tools on both the Nginx worker processes and the RabbitMQ
server processes. It's common that
1. the backend server just cannot catch up with the traffic from Nginx, and/or
2. the Nginx just cannot catch up with the client traffic.
Also, ensure that you use long enough timeout settings (i.e., the
cosocket's settimeout method call).
> How may I make publishing fault tolerant and avoid deduplicating messages in
> concurrent environment by correctly implementing states and reuse sockets
> using cosocket api pool? I set keepalive timeout on the cosocket tcp sock to
> 0 (no timeout as per wiki) and I saw exponential increase in socket consumed
> via the RabbitMQ management web interface, for a load of 100k requests, I
> saw fluctuations between 200-1200 consumed sockets with a lot of socket
> errors.
>
The number of concurrent connections depends on your client requests'
concurrency level. The size of the connection pool does not limit
concurrency because exceeding connections just become "short
connections". You can use Nginx's ngx_limit_conn module to limit the
client requests' concurrency level.
Setting unlimited max idle time for the in-pool connections (i.e.,
specifying 0 for the "max_idle_time" argument in the setkeepalive
call) is generally not a good idea because the client's peak
concurrency level may leave many extra idle connections.
Best regards,
-agentzh