title: Ideal way to do content based routing with two backend instances and one frontend instance
body: <p>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 ?</p>
  <p>Some ways I could think are:</p>
  <ol>
  <li>Use proxy feature in apache and route based on the query string. Was facing some proxy error while trying it.</li>
  <li>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.</li>
  <li>Bake it in the front end code. Configure the two URL's in the frontend code. Route the request based on the country name.</li>
  <li>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.</li>
  <li>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.</li>
  </ol>
  <p><strong>How is currently deployed:</strong></p>
  <p>Our current backend instance is a tomcat server, with apache in the front. The second backend instance will also have the same setup.</p>