I have 2 server running the same service, I want to use ribbon to load balance the traffic between 2 servers, is it possible? I've learn that ribbon can load balance between instance in the server. but my server only have 1 instances, and there are 2 servers. Here is my code to load balance instance, is there any changes i can make to load balance server? Thank you so much!
@SpringBootApplication
@EnableDiscoveryClient
@RestController
@RibbonClient(name= "myInstanceName", configuration=RibbonConfig.class )
public class RibbonAppApplication {
@Inject
private RestTemplate restTemplate;
public static void main(String[] args) {
SpringApplication.run(RibbonAppApplication.class, args);
}
@GetMapping
public String getService() {
return restTemplate.getForEntity("http://myInstanceName",String.class).getBody();
}
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
}