# Dynamic Router

> Routing rules that can be changed at runtime — no redeploy needed.

- **Category**: Integration
- **Subcategory**: Message Routing
- **Canonical URL**: https://designpattern.fyi/patterns/dynamic_router/

---

## Description
Clean, reusable architecture pattern.


## Use Cases
A/B testing for message processing — Dynamic Router sends 80% of checkout messages to checkout-service-v1 and 20% to checkout-service-v2. Ratio is adjusted live via the router's control API without any service restarts.





## Trade-offs


### Advantages

- Routing changes without deployments — huge ops flexibility

- Enables A/B testing, gradual rollouts, and feature flags at the routing layer

- Operators can react to incidents by changing routes instantly

- Rule management can be delegated to non-developer team members




### Considerations & Drawbacks

- External rule store becomes a critical dependency of the router

- Rules must be validated before applying — bad rules can misroute all traffic

- Runtime rule changes can be hard to audit and rollback

- More complex to implement and test than static routing







---
**Reference**: [Original Source](https://www.enterpriseintegrationpatterns.com/patterns/messaging/DynamicRouter.html)

