Reel as an AJAX server

67 views
Skip to first unread message

cootcraig

unread,
Jun 1, 2012, 2:14:15 PM6/1/12
to Celluloid
I have a Tinidad/Sinatra/Celluloid-zmq based server that was just put
into production in our call center. Each AJAX GET into Trinidad/
Sinatra ends in a wait in a Celluloid actor. When the response is
ready a signal is done by another Celluloid actor. This is
functioning properly, but in a days work the thread count hits around
2000 and never goes down. The server application is restarted every
night so for the current load this is working.

I want to try out using reel instead of Trinidad/Sinatra. My thought
is each incoming connection would be immediately handed to a Celluloid
actor and the actor would write the response on the connection. This
would avoid starting separate threads for each AJAX request.

Would this be a good implementation? I would like to be able to scale
this up to perhaps 800 AJAX clients with a request rate of about 1 per
minute each.

Tony Arcieri

unread,
Jun 3, 2012, 12:59:48 PM6/3/12
to cellulo...@googlegroups.com
On Fri, Jun 1, 2012 at 11:14 AM, cootcraig <cr...@coot.net> wrote:
I want to try out using reel instead of Trinidad/Sinatra.  My thought
is each incoming connection would be immediately handed to a Celluloid
actor and the actor would write the response on the connection.  This
would avoid starting separate threads for each AJAX request.

It depends which Ruby implementation you're on. On JRuby, every fiber (which Reel uses to handle a request) maps to a native thread, so Celluloid::IO in general won't help you get your thread count down.

If threads are working for you there's not much reason to switch. The big worry with threads is exhausting memory. Keep in mind that Linux has an O(1) scheduler, so large numbers of threads won't bog the system down any more than small numbers of threads if you're servicing the same amount of load.

--
Tony Arcieri

Tony Arcieri

unread,
Jun 3, 2012, 1:00:33 PM6/3/12
to cellulo...@googlegroups.com
On Sun, Jun 3, 2012 at 9:59 AM, Tony Arcieri <tony.a...@gmail.com> wrote:
It depends which Ruby implementation you're on. On JRuby, every fiber (which Reel uses to handle a request) maps to a native thread, so Celluloid::IO in general won't help you get your thread count down.

Note that the JRuby limitations on Fibers might be moot in the future if the JRuby GSoC project for Kilim integration is successful.

--
Tony Arcieri

Reply all
Reply to author
Forward
0 new messages