In microservice architecture, we will have to develop many microservices. Each microservice may have multiple instances in the ecosystem as per requirement. To overcome this complexity, we have already one popular solution to use service discovery pattern. In spring boot applications, we have couple of options in the service discovery space such as netflix eureka, zookeeper etc.
To overcome the problems of traditional load balancing, client side load balancing came into picture. They reside in the application as inbuilt component and bundled along with the application, so we don’t have to deploy them in separate servers.
Java 8
Maven 3.5.0
Spring Boot 2.0.5.RELEASE
Eclipse
Netflix Eureka as Service Registry Server
Netflix Ribbon as Client Side Load balancer
ribbon-client 1 node
ribbon-eureka-server 1 node
ribbon-server 2 nodes (localhost:9090,localhost:9091)
In this application we implemented a rest service for verifying the load balancing functionality.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>ribbon-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ribbon-client</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Application properties file will be looked like as below.
spring.application.name=client
server.port=8889
eureka.client.serviceUrl.defaultZone= http://${registry.host:localhost}:${registry.port:8761}/eureka/
eureka.client.healthcheck.enabled= true
eureka.instance.leaseRenewalIntervalInSeconds= 1
eureka.instance.leaseExpirationDurationInSeconds= 2
server.ribbon.eureka.enabled=true
server.ribbon.listOfServers=localhost:9090,localhost:9091
server.ribbon.ServerListRefreshInterval=1000
#logging.level.root=TRACE
package com.the.basic.tech.info.ribbonclient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.AvailabilityFilteringRule;
import com.netflix.loadbalancer.IPing;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.PingUrl;
public class RibbonConfiguration {
@Autowired
IClientConfig config;
@Bean
public IPing ribbonPing(IClientConfig config) {
return new PingUrl();
}
@Bean
public IRule ribbonRule(IClientConfig config) {
return new AvailabilityFilteringRule();
}
}
@LoadBalanced annotation being used for enabling the client side load balancing.
package com.the.basic.tech.info.ribbonclient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
@RestController
public class MyClientSideController {
private static final Logger logger = LoggerFactory.getLogger(MyClientSideController.class);
@LoadBalanced
@Bean
RestTemplate restTemplate() {
return new RestTemplate();
}
@Autowired
RestTemplate restTemplate;
@RequestMapping("/client/invokeserver")
public String client() {
logger.info("in ribbon-client");
String randomString = this.restTemplate.getForObject("http://server/backend", String.class);
logger.info("in ribbon-client, after invoking server :: {}", randomString);
return "Server Response :: " + randomString;
}
}
We have to enable discovery client. E.g @EnableDiscoveryClient and @RibbonClient as below
package com.the.basic.tech.info.ribbonclient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
@EnableDiscoveryClient
@SpringBootApplication
@RibbonClient(name = "server", configuration = RibbonConfiguration.class)
public class RibbonClientApplication {
public static void main(String[] args) {
SpringApplication.run(RibbonClientApplication.class, args);
}
}
In this application we implemented/customized a ribbon server for verifying the load balancing functionality.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>ribbon-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ribbon-server</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Application properties file will be looked like as below.
spring.application.name=server
server.port = 9090
eureka.client.serviceUrl.defaultZone= http://${registry.host:localhost}:${registry.port:8761}/eureka/
eureka.client.healthcheck.enabled= true
eureka.instance.leaseRenewalIntervalInSeconds= 1
eureka.instance.leaseExpirationDurationInSeconds= 2
package com.the.basic.tech.info.ribbonserver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MyRestController {
private static final Logger logger = LoggerFactory.getLogger(MyRestController.class);
@Autowired
Environment environment;
@GetMapping("/")
public String health() {
return "I am Up and Running!";
}
@GetMapping("/backend")
public String backend() {
logger.info("Inside MyRestController:: backend.");
String serverPort = environment.getProperty("local.server.port");
logger.info("Server Port : {} ", serverPort);
return "Response form Backend Server!!! " + " Host : localhost " + " :: Port : " + serverPort;
}
}
We need to enable discovery client e.g. @EnableDiscoveryClient
package com.the.basic.tech.info.ribbonserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
@EnableDiscoveryClient
public class RibbonServerApplication {
public static void main(String[] args) {
SpringApplication.run(RibbonServerApplication.class, args);
}
}
In this application we implemented/customized ribbon eureka server for verifying the load balancing functionality.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>ribbon-eureka-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ribbon-eureka-server</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Application properties file will be looked like as below.
spring.application.name= ${springboot.app.name:eureka-serviceregistry}
server.port = ${server-port:8761}
eureka.instance.hostname= ${springboot.app.name:eureka-serviceregistry}
eureka.client.registerWithEureka= false
eureka.client.fetchRegistry= false
eureka.client.serviceUrl.defaultZone: http://${registry.host:localhost}:${server.port}/eureka/
We need to enable EurekaServer e.g. @EnableEurekaServer
package com.the.basic.tech.info.ribboneurekaserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class RibbonEurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(RibbonEurekaServerApplication.class, args);
}
}
2021-06-09 18:06:00.801 INFO 24172 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-06-09 18:06:00.864 INFO 24172 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6866 ms
2021-06-09 18:06:01.665 WARN 24172 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2021-06-09 18:06:01.679 INFO 24172 --- [ost-startStop-1] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2021-06-09 18:06:01.800 INFO 24172 --- [ost-startStop-1] c.netflix.config.DynamicPropertyFactory : DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@3495767
2021-06-09 18:06:11.409 INFO 24172 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2021-06-09 18:06:11.427 INFO 24172 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'webMvcMetricsFilter' to: [/*]
2021-06-09 18:06:11.434 INFO 24172 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2021-06-09 18:06:11.451 INFO 24172 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2021-06-09 18:06:11.453 INFO 24172 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2021-06-09 18:06:11.455 INFO 24172 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpTraceFilter' to: [/*]
2021-06-09 18:06:11.456 INFO 24172 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'servletContainer' to urls: [/eureka/*]
2021-06-09 18:06:11.457 INFO 24172 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2021-06-09 18:06:11.962 INFO 24172 --- [ost-startStop-1] c.s.j.s.i.a.WebApplicationImpl : Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
2021-06-09 18:06:12.400 INFO 24172 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2021-06-09 18:06:12.408 INFO 24172 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2021-06-09 18:06:13.147 INFO 24172 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2021-06-09 18:06:13.301 INFO 24172 --- [ost-startStop-1] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2021-06-09 18:06:15.748 WARN 24172 --- [ main] c.n.c.sources.URLConfigurationSource : No URLs will be polled as dynamic configuration sources.
2021-06-09 18:06:15.818 INFO 24172 --- [ main] c.n.c.sources.URLConfigurationSource : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2021-06-09 18:06:16.352 INFO 24172 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2021-06-09 18:06:17.849 INFO 24172 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@54a52b5c: startup date [Wed Jun 09 18:05:53 IST 2021]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@41b8731a
2021-06-09 18:06:18.093 INFO 24172 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2021-06-09 18:06:18.120 INFO 24172 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2021-06-09 18:06:18.146 INFO 24172 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String org.springframework.cloud.netflix.eureka.server.EurekaController.status(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.Object>)
2021-06-09 18:06:18.150 INFO 24172 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/lastn],methods=[GET]}" onto public java.lang.String org.springframework.cloud.netflix.eureka.server.EurekaController.lastn(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.Object>)
2021-06-09 18:06:18.294 INFO 24172 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2021-06-09 18:06:18.340 INFO 24172 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2021-06-09 18:06:19.836 INFO 24172 --- [ main] o.s.ui.freemarker.SpringTemplateLoader : SpringTemplateLoader for FreeMarker: using resource loader [org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@54a52b5c: startup date [Wed Jun 09 18:05:53 IST 2021]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@41b8731a] and template loader path [classpath:/templates/]
2021-06-09 18:06:19.882 INFO 24172 --- [ main] o.s.w.s.v.f.FreeMarkerConfigurer : ClassTemplateLoader for Spring macros added to FreeMarker configuration
2021-06-09 18:06:20.744 INFO 24172 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2021-06-09 18:06:21.183 INFO 24172 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2021-06-09 18:06:21.189 INFO 24172 --- [ main] com.netflix.discovery.DiscoveryClient : Client configured to neither register nor query for data.
2021-06-09 18:06:21.237 INFO 24172 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1623242181233 with initial instances count: 0
2021-06-09 18:06:21.440 INFO 24172 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initializing ...
2021-06-09 18:06:21.464 INFO 24172 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Adding new peer nodes [http://localhost:8761/eureka/]
2021-06-09 18:06:22.214 INFO 24172 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2021-06-09 18:06:22.243 INFO 24172 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2021-06-09 18:06:22.246 INFO 24172 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2021-06-09 18:06:22.268 INFO 24172 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2021-06-09 18:06:22.932 INFO 24172 --- [ main] c.n.eureka.cluster.PeerEurekaNodes : Replica node URL: http://localhost:8761/eureka/
2021-06-09 18:06:22.978 INFO 24172 --- [ main] c.n.e.registry.AbstractInstanceRegistry : Finished initializing remote region registries. All known remote regions: []
2021-06-09 18:06:23.073 INFO 24172 --- [ main] c.n.eureka.DefaultEurekaServerContext : Initialized
2021-06-09 18:06:23.261 INFO 24172 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2021-06-09 18:06:23.334 INFO 24172 --- [ main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/health],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2021-06-09 18:06:23.380 INFO 24172 --- [ main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/info],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2021-06-09 18:06:23.415 INFO 24172 --- [ main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2021-06-09 18:06:23.717 INFO 24172 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2021-06-09 18:06:23.858 INFO 24172 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'environmentManager' has been autodetected for JMX exposure
2021-06-09 18:06:23.989 INFO 24172 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'refreshScope' has been autodetected for JMX exposure
2021-06-09 18:06:24.118 INFO 24172 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'configurationPropertiesRebinder' has been autodetected for JMX exposure
2021-06-09 18:06:24.248 INFO 24172 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2021-06-09 18:06:24.440 INFO 24172 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2021-06-09 18:06:24.483 INFO 24172 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=54a52b5c,type=ConfigurationPropertiesRebinder]
2021-06-09 18:06:24.543 INFO 24172 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2021-06-09 18:06:24.585 INFO 24172 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application eureka-serviceregistry with eureka with status UP
2021-06-09 18:06:24.695 INFO 24172 --- [ Thread-13] o.s.c.n.e.server.EurekaServerBootstrap : Setting the eureka configuration..
2021-06-09 18:06:24.746 INFO 24172 --- [ Thread-13] o.s.c.n.e.server.EurekaServerBootstrap : Eureka data center value eureka.datacenter is not set, defaulting to default
2021-06-09 18:06:24.779 INFO 24172 --- [ Thread-13] o.s.c.n.e.server.EurekaServerBootstrap : Eureka environment value eureka.environment is not set, defaulting to test
2021-06-09 18:06:24.847 INFO 24172 --- [ Thread-13] o.s.c.n.e.server.EurekaServerBootstrap : isAws returned false
2021-06-09 18:06:24.883 INFO 24172 --- [ Thread-13] o.s.c.n.e.server.EurekaServerBootstrap : Initialized server context
2021-06-09 18:06:24.892 INFO 24172 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8761 (http) with context path ''
2021-06-09 18:06:24.906 INFO 24172 --- [ Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl : Got 1 instances from neighboring DS node
2021-06-09 18:06:24.908 INFO 24172 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8761
2021-06-09 18:06:24.910 INFO 24172 --- [ Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl : Renew threshold is: 1
2021-06-09 18:06:24.912 INFO 24172 --- [ Thread-13] c.n.e.r.PeerAwareInstanceRegistryImpl : Changing status to UP
2021-06-09 18:06:24.917 INFO 24172 --- [ main] .t.b.t.i.r.RibbonEurekaServerApplication : Started RibbonEurekaServerApplication in 38.542 seconds (JVM running for 93.125)
2021-06-09 18:06:24.942 INFO 24172 --- [ Thread-13] e.s.EurekaServerInitializerConfiguration : Started Eureka Server
2021-06-09 18:10:49.521 INFO 21748 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=2b619b83,type=ConfigurationPropertiesRebinder]
2021-06-09 18:10:49.544 INFO 21748 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2021-06-09 18:10:49.588 INFO 21748 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2021-06-09 18:10:49.719 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2021-06-09 18:10:50.179 INFO 21748 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2021-06-09 18:10:50.185 INFO 21748 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2021-06-09 18:10:51.230 INFO 21748 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2021-06-09 18:10:51.231 INFO 21748 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2021-06-09 18:10:51.637 INFO 21748 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2021-06-09 18:10:53.186 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2021-06-09 18:10:53.188 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2021-06-09 18:10:53.189 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2021-06-09 18:10:53.190 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2021-06-09 18:10:53.191 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2021-06-09 18:10:53.195 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2021-06-09 18:10:53.196 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2021-06-09 18:10:53.583 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2021-06-09 18:10:53.605 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 1
2021-06-09 18:10:53.605 INFO 21748 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2021-06-09 18:10:53.621 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1623242453621 with initial instances count: 0
2021-06-09 18:10:53.636 INFO 21748 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application server with eureka with status UP
2021-06-09 18:10:53.636 INFO 21748 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1623242453636, current=UP, previous=STARTING]
2021-06-09 18:10:53.652 INFO 21748 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SERVER/host.docker.internal:server:9090: registering service...
2021-06-09 18:10:53.857 INFO 21748 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9090 (http) with context path ''
2021-06-09 18:10:53.867 INFO 21748 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 9090
2021-06-09 18:10:53.869 INFO 21748 --- [ main] c.t.b.t.i.r.RibbonServerApplication : Started RibbonServerApplication in 23.014 seconds (JVM running for 32.223)
2021-06-09 18:10:54.022 INFO 21748 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SERVER/host.docker.internal:server:9090 - registration status: 204
2021-06-09 18:15:14.560 INFO 18312 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2021-06-09 18:15:14.599 INFO 18312 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2021-06-09 18:15:14.632 INFO 18312 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=c8a6420,type=ConfigurationPropertiesRebinder]
2021-06-09 18:15:14.673 INFO 18312 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2021-06-09 18:15:14.714 INFO 18312 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2021-06-09 18:15:14.806 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2021-06-09 18:15:15.203 INFO 18312 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2021-06-09 18:15:15.203 INFO 18312 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2021-06-09 18:15:15.512 INFO 18312 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2021-06-09 18:15:15.546 INFO 18312 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2021-06-09 18:15:16.125 INFO 18312 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2021-06-09 18:15:17.314 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2021-06-09 18:15:17.314 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2021-06-09 18:15:17.314 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2021-06-09 18:15:17.314 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2021-06-09 18:15:17.314 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2021-06-09 18:15:17.314 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2021-06-09 18:15:17.314 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2021-06-09 18:15:17.584 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2021-06-09 18:15:17.599 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 1
2021-06-09 18:15:17.599 INFO 18312 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2021-06-09 18:15:17.599 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1623242717599 with initial instances count: 1
2021-06-09 18:15:17.615 INFO 18312 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application server with eureka with status UP
2021-06-09 18:15:17.615 INFO 18312 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1623242717615, current=UP, previous=STARTING]
2021-06-09 18:15:17.615 INFO 18312 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SERVER/host.docker.internal:server:9091: registering service...
2021-06-09 18:15:17.700 INFO 18312 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SERVER/host.docker.internal:server:9091 - registration status: 204
2021-06-09 18:15:17.768 INFO 18312 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9091 (http) with context path ''
2021-06-09 18:15:17.781 INFO 18312 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 9091
2021-06-09 18:15:17.789 INFO 18312 --- [ main] c.t.b.t.i.r.RibbonServerApplication : Started RibbonServerApplication in 20.349 seconds (JVM running for 31.801)
2021-06-09 18:18:39.511 INFO 10696 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'environmentManager': registering with JMX server as MBean [org.springframework.cloud.context.environment:name=environmentManager,type=EnvironmentManager]
2021-06-09 18:18:39.531 INFO 10696 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshScope': registering with JMX server as MBean [org.springframework.cloud.context.scope.refresh:name=refreshScope,type=RefreshScope]
2021-06-09 18:18:39.550 INFO 10696 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'configurationPropertiesRebinder': registering with JMX server as MBean [org.springframework.cloud.context.properties:name=configurationPropertiesRebinder,context=35e11f16,type=ConfigurationPropertiesRebinder]
2021-06-09 18:18:39.582 INFO 10696 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2021-06-09 18:18:39.613 INFO 10696 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2021-06-09 18:18:39.715 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : Initializing Eureka in region us-east-1
2021-06-09 18:18:40.080 INFO 10696 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2021-06-09 18:18:40.080 INFO 10696 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2021-06-09 18:18:40.866 INFO 10696 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2021-06-09 18:18:40.866 INFO 10696 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2021-06-09 18:18:41.224 INFO 10696 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2021-06-09 18:18:42.561 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2021-06-09 18:18:42.561 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2021-06-09 18:18:42.561 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2021-06-09 18:18:42.561 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2021-06-09 18:18:42.561 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2021-06-09 18:18:42.561 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2021-06-09 18:18:42.561 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2021-06-09 18:18:42.846 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2021-06-09 18:18:42.862 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 1
2021-06-09 18:18:42.862 INFO 10696 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2021-06-09 18:18:42.877 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1623242922877 with initial instances count: 2
2021-06-09 18:18:42.893 INFO 10696 --- [ main] o.s.c.n.e.s.EurekaServiceRegistry : Registering application client with eureka with status UP
2021-06-09 18:18:42.893 INFO 10696 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1623242922893, current=UP, previous=STARTING]
2021-06-09 18:18:42.893 INFO 10696 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_CLIENT/host.docker.internal:client:8889: registering service...
2021-06-09 18:18:43.009 INFO 10696 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_CLIENT/host.docker.internal:client:8889 - registration status: 204
2021-06-09 18:18:43.031 INFO 10696 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8889 (http) with context path ''
2021-06-09 18:18:43.062 INFO 10696 --- [ main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 8889
2021-06-09 18:18:43.078 INFO 10696 --- [ main] c.t.b.t.i.r.RibbonClientApplication : Started RibbonClientApplication in 19.775 seconds (JVM running for 30.762)
Application logs
=====================================ribbon-client=====================
2021-06-09 18:22:12.995 INFO 10696 --- [erListUpdater-0] c.netflix.config.ChainedDynamicProperty : Flipping property: server.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2021-06-09 18:22:13.409 INFO 10696 --- [nio-8889-exec-1] c.t.b.t.i.r.MyClientSideController : in ribbon-client
2021-06-09 18:22:14.064 INFO 10696 --- [nio-8889-exec-2] c.t.b.t.i.r.MyClientSideController : in ribbon-client, after invoking server :: Response form Backend Server!!! Host : localhost :: Port : 9090
2021-06-09 18:22:14.074 INFO 10696 --- [nio-8889-exec-1] c.t.b.t.i.r.MyClientSideController : in ribbon-client, after invoking server :: Response form Backend Server!!! Host : localhost :: Port : 9091
2021-06-09 18:23:06.198 INFO 10696 --- [nio-8889-exec-7] c.t.b.t.i.r.MyClientSideController : in ribbon-client
2021-06-09 18:23:06.224 INFO 10696 --- [nio-8889-exec-7] c.t.b.t.i.r.MyClientSideController : in ribbon-client, after invoking server :: Response form Backend Server!!! Host : localhost :: Port : 9090
2021-06-09 18:23:42.579 INFO 10696 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
=================================ribbon-server1=========================================
2021-06-09 18:11:23.735 INFO 21748 --- [freshExecutor-0] com.netflix.discovery.DiscoveryClient : The response status is 200
2021-06-09 18:15:53.221 INFO 21748 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2021-06-09 18:20:53.237 INFO 21748 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2021-06-09 18:22:12.087 INFO 21748 --- [nio-9090-exec-3] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2021-06-09 18:22:12.095 INFO 21748 --- [nio-9090-exec-3] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2021-06-09 18:22:12.176 INFO 21748 --- [nio-9090-exec-3] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 76 ms
2021-06-09 18:22:13.578 INFO 21748 --- [nio-9090-exec-1] c.t.b.t.i.ribbonserver.MyRestController : Inside MyRestController:: backend.
2021-06-09 18:22:13.874 INFO 21748 --- [nio-9090-exec-1] c.t.b.t.i.ribbonserver.MyRestController : Server Port : 9090
2021-06-09 18:23:06.215 INFO 21748 --- [nio-9090-exec-3] c.t.b.t.i.ribbonserver.MyRestController : Inside MyRestController:: backend.
2021-06-09 18:23:06.218 INFO 21748 --- [nio-9090-exec-3] c.t.b.t.i.ribbonserver.MyRestController : Server Port : 9090
2021-06-09 18:25:53.249 INFO 21748 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
=================================ribbon-server2=========================================
2021-06-09 18:20:17.340 INFO 18312 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2021-06-09 18:22:11.173 INFO 18312 --- [nio-9091-exec-5] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2021-06-09 18:22:11.183 INFO 18312 --- [nio-9091-exec-5] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2021-06-09 18:22:11.504 INFO 18312 --- [nio-9091-exec-5] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 284 ms
2021-06-09 18:22:13.756 INFO 18312 --- [nio-9091-exec-4] c.t.b.t.i.ribbonserver.MyRestController : Inside MyRestController:: backend.
2021-06-09 18:22:14.052 INFO 18312 --- [nio-9091-exec-4] c.t.b.t.i.ribbonserver.MyRestController : Server Port : 9091
2021-06-09 18:25:17.351 INFO 18312 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
Keep learning. Have a fantastic day 🙂