thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Slee <>
Subject RE: is the thrift client thread safe?
Date Mon, 30 Jul 2012 22:23:13 GMT
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 []
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 looking
to cache the thrift client and was wondering if it could be shared across
multiple threads.


View raw message