Project / resilience for Spring
Kite
Harden a Spring service with a circuit breaker, a concurrency throttle and a rate limiter.
Three guards
Say you want to protect a Spring based service with:
- a circuit breaker that trips after three consecutive exceptions, and retries after 30 seconds;
- a concurrency throttle that rejects requests once there are 50 concurrent requests;
- a rate limiter that rejects anything beyond a client's first 5,000 requests in a given hour.
With Kite, that takes two steps.
Step 1. Create your guards
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
<kite:annotation-config />
<kite:circuit-breaker id="circuitBreaker" exceptionThreshold="3" timeout="30000" />
<kite:concurrency-throttle id="concurrencyThrottle" limit="50" />
<kite:rate-limiting-throttle id="rateLimiter" limit="5000" />
</beans>
Step 2. Annotate your service
@Service
@Transactional
public class MessageServiceImpl implements MessageService {
@GuardedBy({ "concurrencyThrottle", "rateLimiter", "circuitBreaker" })
public List<Message> getMessages() { ... }
}
What the guards do
The circuit breaker stops calls to a failing dependency, then allows a retry after the timeout. The concurrency throttle caps the number of requests in flight. The rate limiter caps the number of requests from a client in a time window.
The guards are declared once and attached to service methods with @GuardedBy. The annotation names map back to the identifiers in the Spring configuration.
Project history
Kite was written for a Spring based service that needed stability controls without a large framework. It moved from Google Code to GitHub in May 2012. The build used Maven, and the continuous integration setup used GitHub, Atlassian Bamboo and a Sonatype Nexus repository.
The project page and the notes are preserved here. Start with Kite documentation for the full setup, or read the build notes:
- Moved Kite from Google Code to GitHub
- Continuous integration with GitHub, Bamboo and Nexus
- All Kite entries