Showing posts with label Ribbon. Show all posts
Showing posts with label Ribbon. Show all posts

Sunday, April 18, 2021

Javabrains POC - Microservices - Part 2 [ Netflix OSS]

https://jsonplaceholder.typicode.com/posts/


https://spring.io/projects/spring-cloud-netflix

Spring Cloud Azure
Spring Cloud for Amazon Web Services
Spring Cloud GCP
Spring Cloud Netflix [Ribbon, Feign, Eureka]
Spring Cloud Kubernetes
Spring Cloud Gateway
Spring Cloud Circuit Breaker
Spring Cloud Config
Spring Cloud OpenFeign
Spring Cloud Consul
Spring Cloud Vault
Spring Cloud Zookeeper

Spring Cloud Netflix OSS 
Feign - Declarative HTTP Client
Eureka - Service Register and Discovery
Ribbon - Client Side Load Balancing
Hytrix - Fault Tolerance Library

Spring Cloud Netflix features:

  • Service Discovery: Eureka instances can be registered and clients can discover the instances using Spring-managed beans

  • Service Discovery: an embedded Eureka server can be created with declarative Java configuration

  • Circuit Breaker: Hystrix clients can be built with a simple annotation-driven method decorator

  • Circuit Breaker: embedded Hystrix dashboard with declarative Java configuration

  • Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations

  • Client Side Load Balancer: Ribbon

  • External Configuration: a bridge from the Spring Environment to Archaius (enables native configuration of Netflix components using Spring Boot conventions)

  • Router and Filter: automatic registration of Zuul filters, and a simple convention over configuration approach to reverse proxy creation


-----------------------------------------------------------------------------------------------------------


Release TrainBoot Version

2020.0.x aka Ilford

2.4.x

Hoxton

2.2.x, 2.3.x (Starting with SR5)

Greenwich

2.1.x

Finchley

2.0.x

Edgware

1.5.x

Dalston

1.5.x


<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>

This is happening because http://microservice_provider_user/ is not a legal host name.

Don't use Underscore for Hostnames


Using Ribbon with Eureka
Use Ribbon Without Eureka
----------------------------------------------------------------------------------------------------------------
Feign

----------------------------------------------------------------------------------------------------------------


----------------------------------------------------------------------------------------------------------------


Thursday, March 25, 2021

JavaBrains Microservices POC

[JavaBrains] [Microservices POC]

https://www.youtube.com/watch?v=y8IQb4ofjDo&list=PLqq-6Pq4lTTZSKAFG6aCDVDP86Qx4lNas


#### Spring Boot Microservices Level 1: Communication and Discovery

https://www.youtube.com/watch?v=y8IQb4ofjDo&list=PLqq-6Pq4lTTZSKAFG6aCDVDP86Qx4lNas  


#### Spring Boot Microservices Level 2: Fault Tolerance and Resilience  

https://www.youtube.com/watch?v=o8RO38KbWvA&list=PLqq-6Pq4lTTbXZY_elyGv7IkKrfkSrX5e


#### Spring Boot Microservices Level 3: Microservice configuration  

https://www.youtube.com/watch?v=upoIwn4rWCo&list=PLqq-6Pq4lTTaoaVoQVfRJPqvNTCjcTvJB


Why , We should not hard-code URLS of Services
  • Code Change for URL modification
  • Dynamic Cloud URL
  • Load Balancer URL - Multi Instance URL
  • Multiple Environment Server URLS

When Services Call Each other, How does a Service1 knows about Service2 URL ?

  • Service Discovery - Design Pattern 
  • Eureka - Technology used for implementing "Service Discovery"


Client Side Service Discovery vs Server Side

Client Side Service Discovery
Client  -> Service Discovery Server
               Looks Up IP address of Service1
           <- Provides IP Address to Client
Client -> Call to Service 1
Client <- Gets a response from Server1

Server-Side Service Discovery
Client Calls Service Discovery asks it to Send "Hi" on its behalf to Service1
Service1 Sends "Hello" response to Discovery Server and its forwarded to Client


Other Technologies which have come from Netflix OSS or developed by Spring Boot
  • Hysterix - Fault Tolerance Library
  • Zuul - Gateway
  • Ribbon
  • Feign


POM Management

spring-cloud-starter-netflix-eureka-server
spring-cloud-starter-netflix-eureka-server

<properties>
	<java.version>11</java.version>
	<spring-cloud.version>2020.0.2</spring-cloud.version>
</properties>
<dependencies>
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter-netflix-eureka-server</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>

  • @LoadBalanced
  • @EnableEurekaClient
  • @EnableEurekaServer


EurekaClient sends heartbeat to EurekaServer
So, If A Service Goes Down, After Maybe about 30 Seconds,
The Entry gets removed from Dashboard of Eureka Server


#### Spring Boot Microservices Level 1: Communication and Discovery
https://www.youtube.com/watch?v=y8IQb4ofjDo&list=PLqq-6Pq4lTTZSKAFG6aCDVDP86Qx4lNas  

#### Spring Boot Microservices Level 2: Fault Tolerance and Resilience  
https://www.youtube.com/watch?v=o8RO38KbWvA&list=PLqq-6Pq4lTTbXZY_elyGv7IkKrfkSrX5e

#### Spring Boot Microservices Level 3: Microservice configuration  
https://www.youtube.com/watch?v=upoIwn4rWCo&list=PLqq-6Pq4lTTaoaVoQVfRJPqvNTCjcTvJB

Adding Spring Cloud To An Existing Spring Boot Application

If you an existing Spring Boot app you want to add Spring Cloud to that app, the first step is to determine the version of Spring Cloud you should use. The version you use in your app will depend on the version of Spring Boot you are using.

The table below outlines which version of Spring Cloud maps to which version of Spring Boot.

Table 1. Release train Spring Boot compatibility
Release TrainBoot Version

2020.0.x aka Ilford

2.4.x

Hoxton

2.2.x, 2.3.x (Starting with SR5)

Greenwich

2.1.x

Finchley

2.0.x

Edgware

1.5.x

Dalston

1.5.x


Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass