사용자 도구

사이트 도구


java:zuul

문서의 이전 판입니다!


Zuul - API Gateway

Netflix의 Client Serving Server

  • Web Browser 혹은 App 등이 접속하는 서버를 API Gateway 로 만들면 안된다.
  • Client Server Adapter Code Server 를 두고 거기서 Client 에게 필요한 정보를 backend service 에 비동기/non-blocking-io 로 요청을 해서 모으고, 그 결과중 필요한 것만 필터링 해서 넘겨줘야 한다.
  • API Gateway 는 이 때 Client Server Adapter 보다 더 앞에서 Client 의 요청을 받아서 처리한다.
  • Netflix 는 Client 의 종류가 TV, PC, Android, iOS 등 너무 다양해서 API Gateway 를 통해서 요청을 받지만 현재 일반적인 서비스는 그런식으로 만드는 경우가 거의 없어서 실질적으로 API Gateway는 필요가 없다

Spring Cloud Neflix Zuul

다중 path 지정

zuul:
  routes:
    myserver_mypath:
      path: /mypath/**
      url: ....
      serviceId: myserver
    myserver_another_path:
      path: /anotherpath/**
      url: ...
      serviceId: myserver

actuator

  • /actuator/routes
  • boot 2.1 의 경우 management.endpoints.web.exposure.include=routes 처럼 지정해 줘야 활성화 됨. 혹은 *

Filter

Service ID 알아내기

* 'org.springframework.cloud.netflix.zuul.filters.support.FilterConstants#SERVICE_ID_KEY'' 사용

  @Override
  public boolean shouldFilter() {
    RequestContext context = RequestContext.getCurrentContext();
    return "member-api".equals(context.get(SERVICE_ID_KEY));
  }

참고

java/zuul.1636420474.txt.gz · 마지막으로 수정됨: 2021/11/09 10:14 저자 kwon37xi