Upload
dharshan-sastry-bn
View
275
Download
6
Embed Size (px)
Citation preview
Spring Cloud & Netflix
Components By SHAS3
Agenda
1. Hystrix2. Eureka 3. Zuul – Router & filter4. Ribbon5. Feign client6. Spring Cloud Config server 7. Spring Cloud Bus8. Q & A?
Why Hystrix?
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.
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.
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/
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
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.
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
Usage
@Configuration@RibbonClient(name = "foo", configuration = FooConfiguration.class)public class TestConfiguration {
}
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.
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.
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
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