title: Load balancing (ribbon) and routing (zuul) Spring REST API (Spring Data JPA) requests to multiple copies of same service
body: <p>I couldn't seem to find a clear example/solution to the following scenario; any help/information would be appreciated!</p>
  
  <p>I have a Spring REST API service that uses Spring Data JPA to interface to a backend database server. I am running this exact same service on multiple machines, and I have a reverse proxy that routes client requests (using Netflix Zuul) to these API services in order to access the data in the database. However, I want to load balance the requests (via the reverse proxy and possibly Netflix Ribbon) so that each request will only be sent to a single API server (in a load-balanced fashion).</p>
  
  <p>Spring Data JPA automatically configures endpoints based on the entity classes and rest repositories I define. One solution would be to generate an equivalent endpoint on the reverse proxy for each and every endpoint on the API services, and then use a Ribbon client to load balance each endpoint individually. However, this does not seem like the appropriate solution.</p>
  
  <p>My question is, does Netflix Zuul or Ribbon provide any functionality to handle this sort of scenario? Essentially, I would like to be able to set a YAML config that simply tells Zuul to use a Ribbon client and automatically load balance all requests to a given endpoint, according to the available listOfServers Ribbon config.</p>
  
  <p>application.yml</p>
  
  <p>Example:</p>
  
  <pre><code>DatabaseAPI:
    ribbon:
      eureka:
        enabled: false
    listOfServers: localhost:8080, localhost:8181, localhost:8282
    ServerListRefreshInterval: 15000
  
  zuul:
    routes:
      data:
        path: /db/**
        ServiceId: DatabaseAPI
  </code></pre>
  
  <p>Now, for example, I want each request to /db/** to be sent to one of the available servers in the server list, in a round-robin fashion. Note: With this example config, every request is sent to ALL the available servers simultaneously. I only want ONE of them to receive each request.</p>