1

In my webflux-application I am consuming messages from AWS-SQS and use them to invoke several HTTP-requests on a slow backend (response times up to 5 seconds).

I realized that the more messages I consume, the slower the backend gets, until it dies, due to too much traffic.

How can I use the reactor / webflux mechanism, to control the number of requests I send to a backend? I tried some stuff with limit / limitRate, but it didn't work as expected.

Do you have any samples/ideas?

Will
  • 413
  • 6
  • 23
Weso
  • 408
  • 4
  • 14
  • [`Flux.limitRate()`](https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#limitRate-int-int-) could well be helpful here, but you'll have to be careful to ensure your source Flux reading from SQS deals with those backpressure signals appropriately. – Michael Berry Oct 22 '19 at 22:08
  • it might be helpful https://stackoverflow.com/questions/52244808/backpressure-mechanism-in-spring-web-flux/52245213#52245213 – Serhii Povísenko Dec 06 '19 at 22:50

1 Answers1

0

Take a look at resilience4j library. Among several resiliency features like circuit breaker, retry, bulkhead there is rate limiting as well.

They support Project Reactor.

Martin Tarjányi
  • 8,863
  • 2
  • 31
  • 49