The article directories

  • Introduction to the
  • Quick start
    • Rely on the import
    • Code sample
    • The configuration file

Introduction to the

Routing is an integral part of the microservices architecture. For example, / might be mapped to your Web application, / API/Users to user services, and/API /shop to store services. Zuul is Netflix’s JVM-based router and server-side load balancer.

Zuul has the following functions:

  • Authentication and certification
  • Insights – Review monitoring
  • Stress Testing – Stress Testing
  • Canary Testing – Canary Testing
  • Dynamic Routing – Dynamic Routing
  • Service Migration – Service Migration
  • Load Shedding – Load Balancer
  • Security – Security
  • Static Response handling – Static Response handling
  • Active/Active Traffic Management – Dynamic traffic management

Zuul’s rules engine enables rules and filters to be written in virtually any JVM language, with built-in support for Java and Groovy.

Configuration properties zuul. Max. Host. Connections are made up of two new attributes to replace, zuul. Host. MaxTotalConnections and zuul. Host. MaxPerRouteConnections defaults to 200 and 20 respectively.

ExecutionIsolationStrategy all the default routing Hystrix isolation mode () for the SEMAPHORE. Zuul. RibbonIsolationStrategy can change for the THREAD whether the isolation mode choice.

Quick start

Rely on the import

 <dependency>
	 <groupId>org.springframework.cloud</groupId>
	 <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
Copy the code

For specific version dependencies, go to start.spring. IO /.

Code sample

Use the @enableZuulProxy annotation to start the proxy. Agents use the Ribbon to locate back-end service instances through service discovery. And all requests are executed in Hystrix Command. So when the circuit breaker is on, the agent will not retry the connection to the back-end service.

Note: Zuul Starter does not include a service discovery client, so to use the service discovery feature, you need to provide a service discovery client (such as Eureka)

@Configuration
@EnableZuulProxy
public class ZuulConfig {}Copy the code

The configuration file

 zuul:
  routes:
    laker:
      path: /laker/**
      url: http://httpbin.org
Copy the code

Request: http://localhost:8080/laker/get will be routed to http://httpbin.org/get.


QQ group [837324215] pay attention to my public number [Java Dfactory interviewer], reply: commonly used tools, resources and other keywords (more keywords, attention after the prompt information) to obtain more free information.

Public accounts will continue to output high-quality articles, and common progress.