Saturday, September 9, 2017

Study about zuul netflix

Zuul is a JVM based router and server side load balancer by Netflix.
It provides a single entry to our system, which allows a browser, mobile app, or other user interface to consume services from multiple hosts without managing cross-origin resource sharing (CORS) and authentication for each one. We can integrate Zuul with other Netflix projects like Hystrix for fault tolerance and Eureka for service discovery, or use it to manage routing rules, filters, and load balancing across your system.





Zuul is a JVM based router and server side load balancer by Netflix.

Zuul is the front door for all requests from devices and web sites to the backend of the Netflix streaming application. As an edge service application, Zuul is built to enable dynamic routing, monitoring, resiliency and security.

Routing in an integral part of a microservice architecture. For example, may be mapped to your web application, /api/users is mapped to the user service and /api/shop is mapped to the shop service. Zuul is a JVM based router and server side load balancer by Netflix.

(dependency)
    (groupId)org.springframework.cloud(/groupId)
    (artifactId)spring-cloud-starter-zuul(/artifactId)
    (version)1.0.4.RELEASE(/version)
(/dependency)

Netflix Zuul to Proxy your Microservices
=======================================
Netflix (a major adopter of microservices) created and open-sourced its Zuul proxy server. Zuul is an edge service that proxies requests to multiple backing services. It provides a unified “front door” to your system, which allows a browser, mobile app, or other user interface to consume services from multiple hosts without managing cross-origin resource sharing (CORS) and authentication for each one. You can integrate Zuul with other Netflix projects like Hystrix for fault tolerance and Eureka for service discovery, or use it to manage routing rules, filters, and load balancing across your system.

The configuration contains three named routes. Each route has a path, which defines the URL mapping in the Zuul server, and a url, which defines the URL of the remote service to proxy

Zuul has the ability to load-balance its services and failover to an alternative service if the primary host goes down.

Adding load balancing and failover
==================================
The Zuul server you deployed comes pre-packaged with Ribbon, a client-side load-balancer, and Hystrix, a fault tolerance library.

Example:
=======
zuul:
  routes:
    httpbin:
      path: /**
      serviceId: httpbin

httpbin:
  ribbon:
    listOfServers: httpbin.org,eu.httpbin.org

ribbon:
  eureka:
    enabled: false

Example2:
========
zuul:
  #Service will be mapped under the /api URI
  prefix: /api
  routes:
    hello-server-url:
      path: /server/**
      url: http://localhost:8071
    hello-server-eurekaId:
      path: /server1/Test/**
      url: HELLO-SERVER
    hello-client:
      path: /client/**
      serviceId: HELLO-CLIENT
    httpbin:
      path: /httpbin/**
      serviceId: httpbin

httpbin:
  ribbon:
    listOfServers: http://localhost:8071,http://localhost:8075

ribbon:
  eureka:
    enabled: false

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8070/eureka/
  instance:
    hostname: localhost

server:
  port: 8079

spring:
  application:
    name: zuul-service

# Increase the Hystrix timeout to 60s (for all)
hystrix:
  command:
    default:
      execution:
        isolation:
          thread:
            timeoutInMilliseconds: 60000

This configuration tells Zuul to forward all requests to the httpbin service, which is defined after the zuul entry. The httpbin entry defines the available servers: httpbin.org and its European counterpart, eu.httpbin.org. If the first host goes down, the proxy will failover to the second host. It also disables Eureka discovery for Ribbon because you don’t have a Eureka server.... yet.


Connecting to Eureka
====================
zuul:
  routes:
    my-service:
      path: /my-service/**
      serviceId: my-service

eureka:
  client:
    serviceUrl:
      defaultZone: ${EUREKA_URL:http://user:password@localhost:5000}/eureka/

The configuration defines a single service route, my-service, which uses a serviceId with the same name. But unlike the Ribbon configuration, you have not defined the my-service details in this file. Instead, Zuul will retrieve them from the Eureka server, which is configured under the eureka entry. It defines the Eureka server’s location at $EUREKA_URL and falls back to a localhost address if it’s not set.  

No comments:

Post a Comment

உப்பு மாங்காய்

சுருக்குப்பை கிழவி. சுருக்கங்கள் சூழ் கிழவி. பார்க்கும் போதெல்லாம் கூடையுடனே குடியிருப்பாள். கூடை நிறைய குட்டி குட்டி மாங்காய்கள். வெட்டிக்க...