I'm using Java. Thanks for the quick response guys! We'll be going with the client-per-thread model then.
-Francis On 7/30/12 3:23 PM, "Mark Slee" <[email protected]> wrote: >Which language are you referring to? > >The general answer is no. I don't believe any of the off-the-shelf client >libraries synchronize access to the underlying socket or buffers in any >way. > >You *may* be able to share the client across threads, if you take >explicit care to lock access to it, ensuring that any thread using the >client holds a lock around the full life-cycle of sending a request, >flushing it, receiving any expected response. > >Wouldn't generally recommend this, though. Think you're better off going >with a client-per-thread model, and keeping your number of threads low >(typically close to the order of your number of cores). Or using a >networker thread model, where worker threads put in requests for the >networker thread to do some work, and just the networker owns the client. > >The simplest way to think about this is that clients are like sockets. >Sharing sockets across threads is generally going to be painful. >________________________________________ >From: Francis Liu [[email protected]] >Sent: Monday, July 30, 2012 3:17 PM >To: [email protected] >Subject: is the thrift client thread safe? > >Hi, > >Thrift noob here. I looked through the documentation was searching the net >for an answer but couldn't find up to date information on this. I'm >looking >to cache the thrift client and was wondering if it could be shared across >multiple threads. > >-Francis > > >
