thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francis Liu <>
Subject Re: is the thrift client thread safe?
Date Tue, 31 Jul 2012 00:41:23 GMT
I'm using Java. 

Thanks for the quick response guys! We'll be going with the
client-per-thread model then.


On 7/30/12 3:23 PM, "Mark Slee" <> 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
>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 []
>Sent: Monday, July 30, 2012 3:17 PM
>Subject: is the thrift client thread safe?
>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
>to cache the thrift client and was wondering if it could be shared across
>multiple threads.

View raw message