spring cloud and netflix components
TRANSCRIPT
![Page 1: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/1.jpg)
Spring Cloud & Netflix
Components By SHAS3
![Page 2: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/2.jpg)
Agenda
1. Hystrix2. Eureka 3. Zuul – Router & filter4. Ribbon5. Feign client6. Spring Cloud Config server 7. Spring Cloud Bus8. Q & A?
![Page 3: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/3.jpg)
Why Hystrix?
![Page 4: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/4.jpg)
![Page 5: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/5.jpg)
Hystrix – Circuit breaker pattern
Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
![Page 6: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/6.jpg)
Service Discovery:Eureka Server
1. Eureka is the Netflix Service Discovery Server and Client. The server can be configured and deployed to be highly available, with each server replicating state about the registered services to the others.
2. When a client registers with Eureka, it provides meta-data about itself such as host and port, health indicator URL, home page etc
3. Eureka receives heartbeat messages from each instance belonging to a service. If the heartbeat fails over a configurable timetable, the instance is normally removed from the registry.
4. @EnableEurekaClient to enable Eureka client.
![Page 7: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/7.jpg)
Eureka Server peer-peer communication
Eureka can be made even more resilient and available by running multiple instances and asking them to register with each other
spring: profiles: peer1eureka: instance: hostname: peer1 client: serviceUrl: defaultZone: http://peer2/eureka/eureka: instance: hostname: peer2 client: serviceUrl: defaultZone: http://peer1/eureka/
![Page 8: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/8.jpg)
Router and Filter: Zuul1. Zuul is a JVM based router and server side load balancer by Netflix.2. Zuul is the front door for all requests from devices and web sites to the backend of the Netflix streaming application.3. Could also be used a reverse proxy server4. Netflix uses Zuul for the following
1. Authentication
2. Insights
3. Stress Testing
4. Canary Testing
5. Dynamic Routing
6. Service Migration
7. Load Shedding
8. Security
9. Static Response handling
10. Active/Active traffic management
![Page 9: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/9.jpg)
![Page 10: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/10.jpg)
Configurationapplication.yml :
1. zuul: routes: users: /myusers/**This means that http calls to "/myusers" get forwarded to the "users" service (for example "/myusers/101" is forwarded to "/101")2. zuul: routes: users: path: /items/price** url: http://example.com/price_service_v2- http calls to "/items/price/**" get forwarded to above URL.
![Page 11: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/11.jpg)
Client Side Load Balancer: Ribbon
1. A central concept in Ribbon is that of the named client.2. Ribbon could be used in conjunction with Eureka server.3. Ribbon could also be used independently by providing
servers list as shown belowstores: ribbon: listOfServers: example.com,google.com
![Page 12: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/12.jpg)
Usage
@Configuration@RibbonClient(name = "foo", configuration = FooConfiguration.class)public class TestConfiguration {
}
![Page 13: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/13.jpg)
Feign Client1. Feign is a declarative web service client. It makes
writing web service clients easier.2. Feign could be used in conjunction with Ribbon to
locate host names.
![Page 14: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/14.jpg)
Config Server
1. A central place to manage external properties for applications across all environments.
2. Exposes REST APIs (could be consumed by any language).
3. Backed by Git.
![Page 15: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/15.jpg)
Spring Cloud Bus
1. Spring Cloud Bus links nodes of a distributed system with a lightweight message broker.
2. Could be used as a communication channel between apps.
3. The only implementation currently is with an AMQP broker as the transport
![Page 16: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/16.jpg)
Configuration & End points
1. Configuration in application.yml :
spring: rabbitmq: host: mybroker.com port: 5672 username: user password: secret
2. /bus/env - sends key/values pairs to update each nodes Spring Environment.
/bus/refresh - will reload each application’s configuration, just as if they had all been pinged on their /refresh endpoint.
/bus/refresh?destination=customers:9000 - where the destination is an ApplicationContext ID
![Page 17: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/17.jpg)
![Page 18: Spring Cloud and Netflix Components](https://reader031.vdocument.in/reader031/viewer/2022020716/5882f4a81a28ab3f1e8b64df/html5/thumbnails/18.jpg)