'Ideal way to do content based routing with two backend instances and one frontend instance
Currently, we have a frontend talking to a backend instance to fetch the data. We have a requirement, where we need to run another backend instance which contains contents different from the first instance. For example, data with country as USA will be stored in the first instance and rest all data in the second instance. Now the request made from the frontend should be routed to the correct backend instance based on the content. E.g. If USA country data is requested it should be forwarded to the first instance, else the second. What are the possible ways to acheive it ?
Some ways I could think are:
- Use proxy feature in apache and route based on the query string. Was facing some proxy error while trying it.
- Use redirection feature in apache. Our frontend keeps requesting data for every second. So too many redirection requests will be fired which might choke our server if many requests are sent.
- Bake it in the front end code. Configure the two URL's in the frontend code. Route the request based on the country name.
- Use a load balancer like Nginx and route the request to the apache server. I am not convinced to have a load balancer to do this, as apache webserver can handle this.
- Have two frontend servers. Each frontend talks to one instance. Use proxy mechanism to reload the frontend instance based on the data. E.g. If USA data is requested, the proxy at the frontend, will route it to the USA based instance and vice versa.
How is currently deployed:
Our current backend instance is a tomcat server, with apache in the front. The second backend instance will also have the same setup.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
