Hystrix/Http Connection Pool Interaction

634 views
Skip to first unread message

Mike Reedell

unread,
Oct 8, 2013, 1:58:57 PM10/8/13
to hystr...@googlegroups.com
In our application, we have Hystrix commands that call external services using an HTTP connection pool (Apache HttpClient 4.2.5). Sometimes these calls fail due to socket read timeouts, connection timeouts, etc. In this case, our getFallback() method in our command object attempts to abort the connection to return it to the pool.

What we're seeing in our logs is the connection pool reaching capacity over time:
From our logs (we dump the connection pool stats in our fallback):
Connection.Pool.Total.Stats=[leased: 200 pending: 0; available: 0; max: 200]

Are there scenarios in Hystrix where a command failure, either via a FAILURE, SHORT_CIRCUITED, or TIMEOUT event could fail to return the http connection back to the pool or are we simply using the wrong semantics when cleaning up a failed command?

-Mike

Dave Ray

unread,
Oct 8, 2013, 3:35:25 PM10/8/13
to Mike Reedell, hystr...@googlegroups.com
Hey,

getFallback() is only intended to provide a fallback value in case a command fails. I wouldn't count on it for cleaning up resources. You should return the connection to the pool in a finally block at the end of your run() method.

Hope this helps,

Dave



--
You received this message because you are subscribed to the Google Groups "HystrixOSS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hystrixoss+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ben Christensen

unread,
Oct 10, 2013, 3:32:38 PM10/10/13
to Dave Ray, Mike Reedell, hystr...@googlegroups.com
Correct, getFallback() is not invoked when run() is successful, so the try/finally needs to be inside run().

-- 
Ben Christensen
+1.310.782.5511 @benjchristensen
Reply all
Reply to author
Forward
0 new messages