Hystrix Buffering / Throttling / Collapsing

416 views
Skip to first unread message

Greg Roodt

unread,
Aug 5, 2016, 7:02:25 AM8/5/16
to HystrixOSS
Hi

What are my options for using Hystrix to Buffer / Throttle peaky traffic? i.e. If I receive a burst of traffic for the same origin resource, but different requests, I'd like them all to be collected into a single origin request.

Is this possible?

Thanks
Greg

Greg Roodt

unread,
Aug 5, 2016, 8:35:23 AM8/5/16
to HystrixOSS
I've experimented with HystrixCollapser and setting Scope to Scope.GLOBAL, but this doesn't seem to be working in a truly Global way.

I can open 2 different tabs and run requests, but it doesn't collapse these. However, if I have a single tab and refresh twice fast, I see it collapse into a single Command. I've set an arbitrary high timerDelayInMilliseconds so I can test this and have time to swap tabs. It is 5000ms.

I find it odd, since it doesn't appear to be request scoping, because I'm not really using this nor have I enabled it in my container.

Greg Roodt

unread,
Aug 5, 2016, 11:29:23 AM8/5/16
to HystrixOSS
I'm starting to have my doubts as to whether this is even possible in Hystrix. I've started to play around with 'shardRequests', but can't get it to work correctly.

Any advice on whether this is possible would be very helpful.

Greg Roodt

unread,
Aug 5, 2016, 3:11:19 PM8/5/16
to HystrixOSS
I guess that I misunderstand the Collapser. The behaviour I'm looking for is more like the HystrixCache, but scoped globally. I wonder if Hystrix can support a Global Cache with a time window?

Matt Jacobs

unread,
Aug 5, 2016, 4:25:15 PM8/5/16
to HystrixOSS
The Hystrix RequestCache is for de-duplicating commands with the same key/name and the same arguments.  Something like GetCustomer(123), GetCustomer(123).  When used, the 2nd-nth commands are not executed, but the value from the first is returned as soon as available.  This is Request-scoped only

The Hystrix Collapser is for batching commands with the same key/name and different arguments.  Something like GetCustomer(123), GetCustomer(999).  When used, all commands invocations in a certain time slice get batched up into a single command (Ex: GetCustomers(123, 999)).  This can happen within a single request or globally.  

There's no global cache for commands.  If you want to build one outside Hystrix, that's certainly an option.  

-Matt

Greg Roodt

unread,
Aug 7, 2016, 1:39:39 PM8/7/16
to HystrixOSS
Thanks Matt. You've confirmed my new understanding. It's a pity that there isn't an out-of-the-box way to use the HystrixCache under global scope.
Reply all
Reply to author
Forward
0 new messages