티스토리 뷰

프로그래밍/spring

Zuul 이해하기

앙망 2019. 2. 7. 16:49

https://cloud.spring.io

19. Router and Filter: Zuul

사용목적

라우팅은 마이크로서비스 아키넥쳐의 필수요소이다. Zuul은 JVM기반의 라우터로 Nextflix에서 사용하는 서버사이드 로드 밸러서이다.
  • Authentication
  • Insights
  • Stress Testing
  • Canary Testing
  • Dynamic Routing
  • Service Migration
  • Load Shedding
  • Security
  • Static Response handling
  • Active/Active traffic management
zuul 동작의 이해

Zuul Request Lifecycle

zuul-request-lifecycle.png

필터유형 Filter Types

There are several standard Filter types that correspond to the typical lifecycle of a request:
  • PRE Filters : origin으로 라우팅 되기 전에 실행된다.
    Examples include request authentication, choosing origin servers, and logging debug info.
  • ROUTING Filters : origin의 request되는 라우팅을 처리한다. 여기서는 원래의 request(the origin HTTP request)가 만들어지고 Apache HttpClient 나 Netflix Ribbon을 사용하여 전송된다.
  • POST Filters : request가 본거지에 라우트된 후 실행된다. Examples include adding standard HTTP headers to the response, gathering statistics and metrics, and streaming the response from the origin to the client.
  • ERROR Filters : execute when an error occurs during one of the other phases.
Alongside the default Filter flow, Zuul allows us to create custom filter types and execute them explicitly. For example, we have a custom STATIC type that generates a response within Zuul instead of forwarding the request to an origin. We have a few use cases for this, one of which is internal endpoints that contain debug data about a particular Zuul instance.
댓글