Sa�l Ibarra Corretg�
http://bettercallsaghul.com
Sa�l Ibarra Corretg�
http://bettercallsaghul.com
If we call uv_queue_work unconditionally it goes on creating thousands of threads (I did see it through Windows task manager). It was becoming tough to manage resources in that case. To avoid that, I call uv_work_queue only for predefined number of times, and next call(s) will occur only after I got callback(s) to previous call(s).
My event loop puts incoming data (requests) in a queue and routine passed to uv_work_queue (thread) processes those requests in queue sequentially. Thus, event loops job is only to dump incoming requests to queue through on_read callback, and to attend other callbacks (after_work_cb, tty callback etc)
Currently it is simple echo server. So nothing much I am doing in threads except copy the request (for sake of doing something), so that after_work_cb can send it back to client.
It all works fine. But when I simulate thousands of connections those bombards my server with continuous asynchronous requests, event loop keeps invoking only on_read callback. Thus, after_work_cb never gets called and my request queue goes on increasing forever to system memory limits. (TTY callback also never gets called but I guess underlying reason might be the same for both)
What I observed additionally is, once I stop simulator, event loop immediately resumes calling back these other callback.
Tnx,
Ashish
Hi,
>
> Hi Sa�l,
Sa�l Ibarra Corretg�
bettercallsaghul.com
>
> Hi Sa�l,
Sa�l Ibarra Corretg�
bettercallsaghul.com