Routing is one of the features added to WCF 4.0, which brings some quite nice features:
- Content-based load balancing
- Automatically use of fallback services
- Protocol bridging
- Masking of versioning issues
In an attempt to get familiar with Routing, I took the first scenario, where we will use content-based load balancing routing.
We have an OrderService which is accepting orders and processes these orders. From time to time we experience some peak loads, which somewhat worried our managers. They do not care all that much about latency and the speed of the order processing in general, except for our high stake clients (you know how some managers are). They value the orders of our high stake clients a lot higher then the general order and they want to make sure we can guarantee that the high stake orders do not experience anything if we would have some sort of peak in order submitting.
Obviously there are multiple ways to improve our scenario, like decent throttling, load balancing, queues and so forth. But a possible solution could aswell be provided with the WCF 4.0 routing.
Instead of having 1 OrderService like we have now, we will bring up another OrderService, so we will be having 2 OrderService’s. We will not simply load balance the requests to these 2 services round robin, but we will load balance the order request based on the content. We will route all orders with a total order price of $500 to the 2nd service we brought up. All the orders with a lower total price will still be routed to our current OrderService.
For pure load balancing purposes, you could also bring up multiple OrderServices and put a WCF Router in front of it, which distributes the requests round robin. You clients send the messages to the router, and the router just forwards to the processing services.