thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From BCG <bgo...@hushmail.com>
Subject Re: How to make a Thrift client for multiple threads?
Date Tue, 07 Jun 2016 13:29:15 GMT

On 06/07/2016 07:54 AM, Matt Chambers wrote:
> Another way to do it would be to use ThreadLocal connections.
> https://docs.oracle.com/javase/8/docs/api/java/lang/ThreadLocal.html <https://docs.oracle.com/javase/8/docs/api/java/lang/ThreadLocal.html>
>
>> On Jun 7, 2016, at 6:14 AM, Daniel Wu <qiang.wu@dianrong.com> wrote:
>>
>> Thrift client/connection is not thread safe. Use a lock or object pool.
>>
>> On 7/6/2016, 5:51 PM, "Tuan Le Dinh" <ldtuanbk@gmail.com> wrote:
>>
>>
You might not see too much gain in simply pooling/locking/reusing 
clients, as the real overhead that you are trying to avoid (I presume) 
is the overhead of establishing connections.  Simply reusing THttpClient 
might not avoid this overhead.

In addition to (or perhaps instead of) reusing client instances you 
might want to investigate the connection pooling functionality built 
into Commons HTTP Components:

https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html

You could, for example, manually configure an HttpClient instance to use 
connection pooling and then just pass that instance to the 
THttpClient(String url, HttpClient client) constructor.


Mime
View raw message