From: "s.ross" Date: 2009-04-25T05:40:57+09:00 Subject: Re: Q: Architecting large Web service download app in Ruby On Apr 24, 2009, at 11:14 AM, James Gray wrote: > On Apr 24, 2009, at 12:44 PM, s.ross wrote: > >> Is there a thread-safety issue in net/http that is causing results >> to be stepped on? > > I can't say I know for sure, but I'm doubting it. > >> If that's the case, does a different approach suggest itself? > > Well, you can fork() processes instead of Threads, if your not on > Windows. This would eliminate Thread safety concerns. You may have > to work out some IPC issues though if each process can't work > totally on its own. > > James Edward Gray II Ok, I looked into it further, and there is a thread safety issue and it's in the xml-rpc library. If you use the call method in a thread, you can have the response buffer overwritten by a response in another thread. However, if you use call_async, then a new server connection and response buffer is used, thereby rendering it thread safe. And the performance win is astonishing! Using a separate process with database connections either means dRb and some interesting IPC, BackgroundRb, or something else like that. I'm just pleased that I could bring the average turnaround per request from 65ms to 4ms (leveled at 1000 combination calls the the master and detail services). W00t!