From: Francis Cianfrocca Date: 2006-08-06T15:16:49+09:00 Subject: Re: threads and system calls snacktime wrote: > I'm curious how ruby threads would do for a threaded network server. > Will reading/writing sockets in one thread block other threads? In > this application clients connect to the server via ssl and a simple > line protocol. They send requests to the server, and the server in > turn makes https connections to yet another server, gets the response, > and sends it's own response back to the client. Clients can send > multiple requests and stay connected as long as they want. > > The servers that the application makes an https connection to speak > 5-6 different protocols. Right now we have one application written in > perl that speaks 2 of them, and one in python's twisted that speaks > another. I want to consolidate everything into one application so I'm > evaluating my options. Perl is ok, no real complaints. Twisted is > amazingly fast for how few resources it consumes, but the code is > rather complicated and I'm not sure it's worth the extra performance. > I've used ruby for a while now but haven't used ruby threads and not > sure what kinds of issues I would run into with an application like > this. The application would need to be able to handle 20-30 > concurrent clients each sending one request every 3-4 seconds. So > figure 40 or so ssl connections per second at the most plus the > connected clients, which will usually stay connected for long periods > of time. > > Any advice or suggestions would be welcome. Look at EventMachine (Rubyforge) for a ruby implementation of something much like Twisted at least as fast and relatively efficient too. EM supports SSL, can easily handle multiple protocols and isn't very hard to use. The latest (unpublished) versions support thread-pools and locally-blocking functions (like Twisted's Deferreds) if you need them. We don't have a large library of standard protocols like Twisted yet, but they are coming. -- Posted via http://www.ruby-forum.com/.