Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Service Throttling ability in Spring Boot

Is there any way to achieve the service throttling ability to the rest services in Spring, particular with Spring boot.

The Expectation here is: My services are exposed to outside world, currently there are no restrictions on the number of service calls per second/min. We want to control this by putting the throttling limit.

  • I have an alternative option, by tracking the requests in concurrent Hash Map or any caching mechanism.

But more interested in the way spring in considering this. I know that i can be able to do it in node.js / scala

like image 930
Kiran Parepalli Avatar asked Dec 21 '16 04:12

Kiran Parepalli


1 Answers

There is a fairly new opensource project which handles this:

https://github.com/shlomokoren/spring-boot-throttling

Declarative approach of throttling control over the Spring services. @Throttling annotation helps you to limit the number of service method calls per java.util.concurrent.TimeUnit for a particular user, IP address, HTTP header/cookie value, or using Spring Expression Language (SpEL).

like image 178
trf Avatar answered Oct 30 '22 23:10

trf