본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

업스트림

원문 보기 위키 갱신

업스트림 (Upstream)

업스트림은 가상 호스트 이름과 여러 타깃(Target)을 묶어서 로드 밸런싱을 가능하게 해 주는 엔티티예요. 서비스가 호스트를 직접 가리키는 대신 업스트림을 가리키도록 구성하면, 여러 타깃 사이에서 요청을 분산하고 장애가 생긴 서버는 자동으로 우회할 수 있어요. 여기에 헬스 체크, 서킷 브레이커, 그리고 라운드 로빈이나 일관된 해싱 같은 다양한 로드 밸런싱 알고리즘까지 더해져요. 이 문서에서는 업스트림의 개념부터 사용 사례, 알고리즘, 설정 방법까지 차근차근 살펴봐요

출처: 문서

본문

Upstream이란 무엇인가요?

Upstream은 가상 호스트명과, 클라이언트 요청이 전달되는 Target들 즉 업스트림 서비스 인스턴스 모음을 제공해서 로드 밸런싱을 가능하게 해요.

Upstream을 사용하면 여러 Gateway Service에 걸쳐 들어오는 요청을 헬스 체크하고, 서킷 브레이크하며, 로드 밸런싱할 수 있어요. 또한 Upstream 엔티티는 least-connections, consistent-hashing, lowest-latency 같은 더 고급 기능의 알고리즘도 갖추고 있어요.

Upstream과 Gateway Service의 상호작용

Service가 호스트 대신 Upstream을 가리키도록 설정할 수 있어요. 예를 들어 example_service라는 Service와 example_upstream이라는 Upstream이 있다면, 호스트를 지정하는 대신 example_service를 example_upstream을 가리키게 할 수 있어요. 그러면 example_upstream Upstream은 httpbin.konghq.com과 httpbun.com이라는 서로 다른 두 Target을 가리킬 수 있어요. 실제 환경에서는 Upstream이 여러 시스템에서 실행되는 동일한 Service를 가리켜요.

이 구성을 사용하면 업스트림 Target들 사이에서 로드 밸런싱을 할 수 있어요. 예를 들어 업스트림 서비스가 서로 다른 두 서버, 즉 업스트림 Target에 걸쳐 배포되어 있다면 Kong Gateway는 두 서버 모두에 걸쳐 로드 밸런싱을 해야 해요. 서버 중 하나(앞선 예시의 httpbin.konghq.com 같은)를 사용할 수 없게 되면 자동으로 문제를 감지해서 정상 동작 중인 서버(httpbun.com)로 모든 트래픽을 라우팅해요.

다음 다이어그램은 Upstream이 다른 Kong Gateway 엔티티와 어떻게 상호작용하는지 보여줘요:

 
flowchart LR

  A("Request")
  B("`Route 
  (/mock)`")
  C("`Service
  (example_service)`")
  D("Target:
  httpbin.konghq.com")
  E("Target:
  httpbun.com")
  F(Upstream service:
  httpbin.konghq.com)
  G(Upstream service:
  httpbun.com)

  A --> B
  subgraph id1 ["`**KONG GATEWAY**`"]
    B --> C --> D & E
  subgraph id3 ["`**Upstream** (load balancer)`"]
  
    D & E
  end

  end

  subgraph id2 ["`**Target upstream services**`"]
    D --> F
    E --> G

  end

  style id2 stroke:none!important
  

Upstream의 활용 사례

다음은 Upstream의 일반적인 활용 사례 예시예요:

로드 밸런싱

설명: Upstream이 여러 업스트림 Target을 가리키는 경우, Upstream 엔티티를 설정해서 Target들 사이에서 트래픽을 로드 밸런싱할 수 있어요. 로드 밸런싱이 필요 없다면, 요청을 라우팅하고 트래픽을 프록시하는 방법으로는 Route의 host 헤더를 사용하는 것을 권장해요.

헬스 체크

설명: Upstream을 설정하면 Target을 동적으로 정상(healthy) 또는 비정상(unhealthy) 상태로 표시할 수 있어요. 이는 능동 검사(active check) 방식으로, Target 내의 특정 HTTP 또는 HTTPS 엔드포인트에 주기적으로 요청을 보내고 그 응답을 기준으로 Target의 상태를 판단해요.

서킷 브레이크

설명: Upstream을 설정하면 Kong Gateway가 프록시되는 진행 중인 트래픽을 수동적으로 분석하고, 요청에 응답하는 동작을 기준으로 Target의 상태를 판단할 수 있어요.

로드 밸런싱 알고리즘

로드 밸런서는 다음 로드 밸런싱 알고리즘을 지원해요:

  • round-robin
  • consistent-hashing
  • least-connections
  • latency
  • sticky-sessions v3.11+

참고: 헬스 체크를 사용하는 경우, 비정상(unhealthy) 상태의 Target은 로드 밸런서에서 제거되지 않고, 해싱 알고리즘을 사용할 때 밸런서 배치에도 어떤 영향도 주지 않아요. 대신 비정상 상태의 Target은 단순히 건너뛰어져요.

Round-robin

round-robin 알고리즘은 가중치 방식으로 수행돼요. 기본 DNS 기반 로드 밸런싱과 동일한 결과를 제공하지만, upstream이기 때문에 헬스 체크와 서킷 브레이커를 위한 추가 기능도 함께 사용할 수 있어요.

이 알고리즘을 선택할 때는 다음 사항을 고려하세요:

  • 요청 분산이 우수해요.
  • 꽤 정적인 상태를 유지해요. 트래픽 분산에 영향을 줄 수 있는 것은 DNS 업데이트나 Target 업데이트뿐이거든요.
  • 캐시 히트 비율을 개선하지 않아요.

Consistent-hashing

consistent-hashing 알고리즘에서는 설정 가능한 클라이언트 입력을 사용해서 해시 값을 계산해요. 이 해시 값은 이후 특정 백엔드 서버에 묶여요.

일반적인 예로는 consumer를 해시 입력으로 사용하는 경우가 있어요. 이 ID는 해당 사용자의 모든 요청에서 동일하기 때문에, 같은 사용자가 항상 같은 백엔드 서버에서 일관되게 처리되도록 보장해요. 덕분에 각 서버가 고정된 사용자 집합만 처리하게 되므로 백엔드에서 캐시 최적화가 가능하고, 사용자 관련 데이터에 대한 캐시 히트 비율을 높일 수 있어요.

이 알고리즘은 ketama 원리를 구현해서 해시 안정성을 최대화하고, 알려진 백엔드 목록에 변경이 생길 때 일관성 손실을 최소화해요.

consistent-hashing 알고리즘의 입력은 hash_on 파라미터에 설정된 값에 따라 다음 옵션 중 하나가 될 수 있어요:

none

설명: consistent-hashing을 사용하지 않고 대신 round-robin을 사용해요(기본값). 해싱은 비활성화돼요.

consumer

설명: Consumer ID를 해시 입력으로 사용해요. Consumer ID를 사용할 수 없으면 Credential ID로 폴백해요(예: LDAP 같은 외부 인증 메커니즘을 사용하는 경우).

ip

설명: 출발 IP 주소를 해시 입력으로 사용해요. 이 옵션을 사용할 때는 실제 IP 판별을 위한 설정을 확인하세요.

설명: 지정된 헤더를 해시 입력으로 사용해요. 헤더 이름은 header가 기본 속성인지 폴백 속성인지에 따라 Upstream의 hash_on_header 또는 hash_fallback_header 필드에 각각 지정돼요.

설명: | 지정된 경로를 가진 특정 쿠키를 해시 입력으로 사용해요. 쿠키 이름은 Upstream의 hash_on_cookie 필드에 지정하고, 경로는 Upstream의 hash_on_cookie_path 필드에 지정해요. 요청에 지정된 쿠키가 없으면 응답을 통해 설정돼요. 생성된 쿠키는 무작위 UUID 값을 가지며, 이 값이 쿠키에 그대로 유지돼요.

cookie가 기본 해싱 메커니즘이면 hash_fallback 설정은 유효하지 않고 사용할 수 없어요. consistent-hashing 알고리즘은 기본(primary) 해싱 속성과 폴백(fallback) 해싱 속성을 지원해요. 기본 속성이 실패하면(예를 들어, 기본 속성이 consumer로 설정되어 있는데 인증된 Consumer가 없는 경우) 폴백 속성이 사용돼요. 이렇게 하면 업스트림 캐시 히트를 최대화할 수 있어요.

consistent-hashing 밸런서는 단일 노드 환경과 클러스터 환경 모두에서 동작하도록 설계됐어요.

이 알고리즘을 선택할 때는 다음 사항을 고려하세요:

  • 백엔드 캐시 히트 비율을 개선해요.
  • 균등하게 분산되려면 해시 입력에 충분한 카디널리티가 필요해요. 예를 들어, 가능한 값이 2개뿐인 헤더를 해싱하는 것은 의미가 없어요.
  • 쿠키 기반 방식은 브라우저 기반 요청에는 잘 동작하지만, 쿠키를 종종 생략하는 머신 투 머신(M2M) 클라이언트에는 그다지 적합하지 않아요.
  • Kong Gateway 클러스터에서 해싱 방식을 사용할 때는 Target 엔티티를 IP 주소로 추가하고, 밸런서에서 호스트네임 사용은 피하세요. DNS TTL은 초 단위 정밀도만 가지고, 갱신 시점은 이름이 실제로 요청되는 시점에 따라 결정되기 때문에 밸런서들은 서서히 어긋나게 돼요. 게다가 일부 네임서버는 모든 엔트리를 반환하지 않아서 문제가 더 악화돼요. 이 문제는 밸런서 재빌드와 더 높은 TTL 설정으로 완화할 수 있어요.

최소 연결(Least-connections)

least-connections 알고리즘은 각 백엔드에서 처리 중인(in-flight) 요청 수를 추적해요. 가중치는 백엔드의 연결 용량을 계산하는 데 사용돼요. 요청은 여유 용량이 가장 큰 백엔드로 라우팅돼요.

이 알고리즘을 선택할 때는 다음 사항을 고려하세요:

  • 트래픽 분산이 잘 돼요.
  • 캐시 히트 비율은 개선되지 않아요.
  • 이 옵션은 더 동적이에요. 느린 백엔드에는 열려 있는 연결이 더 많아지고, 새 요청은 자동으로 다른 백엔드로 라우팅되기 때문이에요.

지연 시간(Latency)

latency 알고리즘은 peak EWMA(Exponentially Weighted Moving Average, 지수 가중 이동 평균)를 기반으로 하며, 밸런서가 가장 낮은 지연 시간(upstream_response_time)을 기준으로 백엔드를 선택하도록 보장해요. 사용되는 지연 시간 지표는 TCP 연결부터 본문 응답 시간까지의 전체 요청 주기예요. 이동 평균이기 때문에 지표는 시간이 지나면서 감쇠해요.

Target 가중치는 고려되지 않아요.

이 알고리즘을 선택할 때는 다음 사항을 고려하세요:

  • 지표가 항상 감쇠하기 때문에, 지표를 유지할 수 있을 만큼 충분한 기본 부하가 있다면 트래픽 분산이 잘 돼요.
  • 이 알고리즘은 끊임없이 부하를 최적화하기 때문에 매우 동적이에요.
  • 지연 시간 기반 로드 밸런싱은 지연 시간 편차가 낮을 때, 즉 트래픽 형태가 대체로 비슷하고 백엔드의 워크로드가 고를 때 가장 잘 동작해요. 예를 들어, 작고 빠른 쿼리와 크고 느린 쿼리를 모두 처리하는 GraphQL 백엔드에 이 알고리즘을 사용하면 지연 시간 지표의 편차가 커져서 지표가 왜곡돼요.
  • 리소스 고갈(resource starvation)을 방지하려면 백엔드 용량을 적절히 설정하고 네트워크 지연 시간도 적절히 확보해야 해요. 예를 들어 서버 2대를 사용할 수 있어요. 가까운 곳에 있는 소용량 서버(네트워크 지연 시간 낮음)와, 먼 곳에 있는 고용량 서버(지연 시간 높음)예요. 대부분의 트래픽은 소용량 서버의 지연 시간이 올라가기 시작할 때까지 그쪽으로 라우팅돼요. 하지만 지연 시간이 올라간다는 것은 소용량 서버가 리소스 고갈을 겪고 있을 가능성이 높다는 뜻이에요. 이 경우 알고리즘은 소용량 서버를 계속 리소스 고갈 상태로 유지하게 되는데, 이는 대체로 효율적이지 않아요.
  • 이 옵션은 웹소켓이나 server-sent events(SSE) 같은 장기 연결에는 적합하지 않아요.

스티키 세션(Sticky sessions) v3.11+

스티키 세션을 사용하면 Kong Gateway가 브라우저가 관리하는 쿠키를 이용해 같은 클라이언트의 반복 요청을 같은 백엔드 Target으로 라우팅할 수 있어요.

sticky-sessions 알고리즘을 사용하는 Upstream을 통해 요청이 프록시되면, Kong Gateway가 응답에 쿠키를 설정해요(Set-Cookie 헤더를 통해). 이후 요청에서 쿠키가 아직 유효하고 원래 Target을 사용할 수 있다면, 트래픽은 같은 Target으로 라우팅돼요.

이 메커니즘은 세션 지속성, 그레이스풀 셧다운(graceful shutdown), 연결 어피니티(connection affinity)가 필요한 애플리케이션에 유용해요.

이 알고리즘을 선택할 때는 다음 사항을 고려하세요:

  • 브라우저가 관리하는 쿠키를 통해 세션 지속성을 제공해요.
  • 완전히 제거될 때까지 종료 중이거나 NotReady 상태인 pod로 트래픽 라우팅을 계속해요.
  • Target이 드레인되거나 종료되는 동안에도 스티키 동작이 필요한 애플리케이션에 이상적이에요.
  • 일부 클라이언트가 특정 Target에 묶인 긴 세션을 유지하면 부하가 고르지 않을 수 있어요.

쿠키 설정은 Upstream별로 커스터마이즈할 수 있어요:

{
  "name": "sticky",
  "algorithm": "sticky-sessions",
  "hash_on": "none",
  "hash_fallback": "none",
  "sticky_sessions_cookie": "gruber",
  "sticky_sessions_cookie_path": "/"
}

스티키 세션 vs consistent hashing

다음 표는 스티키 세션이 consistent hashing과 어떻게 다른지 설명해요:

세션 어피니티(Session Affinity)

스티키 세션: 쿠키를 통해 강제돼요. consistent hashing: 해시 입력(예: IP 또는 헤더)에 의존해요. Target이 변경되면 지속성이 없어요.

Target 제거 처리(Target Removal Handling)

스티키 세션: 원래 Target이 제거되면 새 Target을 선택해요. consistent hashing: 사용 가능한 Target을 기준으로 최소한의 조정만 해요.

부하 분산(Load Distribution)

스티키 세션: 오래 지속되는 세션이 있으면 부하가 고르지 않을 수 있어요. consistent hashing: 균등한 분산을 위해 설계됐어요.

Pod 드레인 지원(Pod Draining Support)

스티키 세션: NotReady 상태이거나 종료 중인 pod로 라우팅을 계속해요. consistent hashing: 상태가 좋지 않거나 종료 중인 pod로의 라우팅은 피해요.

장애 조치(failover) Target 관리 v3.12+

Upstream에 연결된 다른 일반 Target(failover: false)들이 unhealthy 상태일 때, 어떤 Target을 장애 조치(백업) Target으로 사용하도록 failover: true로 설정할 수 있어요. 장애 조치 Target은 모든 일반 Target이 unhealthy 상태일 때만 사용돼요. 하나의 Upstream에 장애 조치 Target을 하나 또는 여러 개 설정할 수 있어요.

latency, least-connections, round-robin 로드 밸런싱 알고리즘이 장애 조치 Target을 지원해요.

참고: consistent-hashing 또는 sticky session 로드 밸런싱 알고리즘을 사용하는 Upstream에 장애 조치 Target을 설정하면, 이 Target들은 일반 로드 밸런싱이나 장애 조치 용도로 사용되지 않아요.

다음은 장애 조치 Target 설정 예시예요:

decK

다음은 example_upstream이라는 새 Target을 생성해요:

_format_version: "3.0"
upstreams:
  - name: example_upstream
    targets:
    - target: 192.168.1.3:8080
      weight: 50
      failover: true

{: data-file="kong.yaml" data-tool="deck" }

Admin API

Target을 생성하려면 Admin API의 /targets 엔드포인트를 호출하세요.

curl -i -X POST http://localhost:8001/upstreams/{upstreamName|Id}/targets/ \
    --header "Accept: application/json" \
    --header "Content-Type: application/json" \
    --data '
    {
      "target": "192.168.1.3:8080",
      "weight": 50,
      "failover": true
    }
    '

Konnect API

Target을 생성하려면 Konnect 컨트롤 플레인 config API의 /targets 엔드포인트를 호출하세요.

curl -X POST https://{region}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/upstreams/{upstreamId}/targets/ \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer $KONNECT_TOKEN" \
    --data '
    {
      "target": "192.168.1.3:8080",
      "weight": 50,
      "failover": true
    }
    '

다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:

  • region: Kong Konnect가 호스팅되고 운영되는 지리적 지역이에요.

  • KONNECT_TOKEN: Konnect 계정과 연결된 여러분의 개인 액세스 토큰(PAT)이에요.

  • controlPlaneId: 컨트롤 플레인의 id예요.

지역별 URL과 개인 액세스 토큰에 대해 자세히 알아보려면 Konnect Control Planes Config API 레퍼런스를 확인하세요.

KIC

Kong Ingress Controller는 Kubernetes 클러스터에서 발견된 엔드포인트를 기반으로 Target을 자동으로 구성해요.

Terraform

사전 조건: 개인 액세스 토큰 구성
terraform {
  required_providers {
    konnect = {
      source  = "kong/konnect"
    }
  }
}

provider "konnect" {
  personal_access_token = "$KONNECT_TOKEN"
  server_url            = "https://us.api.konghq.com/"
}

Terraform 구성에 다음을 추가하세요:

resource "konnect_gateway_target" "my_target" {
  target = "192.168.1.3:8080"
  weight = 50
  failover = true

  upstream_id = konnect_gateway_upstream.my_upstream.id
  control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
}

UI

다음은 기본 구성으로 새 Upstream과 Target을 생성하는 방법이에요:

  1. Gateway 인스턴스로 이동하세요:
  • Konnect 사이드바에서 API Gateway > Gateways를 클릭한 다음 컨트롤 플레인을 선택하세요.
  • Kong Manager에서 Workspace를 선택하세요.
  1. Upstreams로 이동하세요:
  • Konnect에서 컨트롤 플레인 안에 있는 Upstreams 탭을 클릭하세요.
  • Kong Manager에서 사이드바의 Upstreams를 열어요.
  1. New upstream을 클릭하세요.
  2. Upstream의 고유한 이름을 입력하세요. 예를 들어: example_upstream.
  3. Save를 클릭하세요.
  4. 해당 Upstream에서 Targets 탭을 클릭하세요.
  5. New target을 클릭하세요.
  6. Target Address 필드에 IP 주소/호스트명과 포트를 입력하세요. 예를 들어: 192.168.1.3:8080
  7. 가중치를 업데이트하세요. 예를 들어: 50.
  8. Save를 클릭하세요.

전체 튜토리얼은 장애 발생 시 백업 Target으로 요청 라우팅을 확인하세요.

Upstream 설정

decK

다음은 example-upstream이라는 새 Upstream을 생성해요:

_format_version: "3.0"
upstreams:
  - name: example-upstream
    algorithm: round-robin

{: data-file="kong.yaml" data-tool="deck" }

Admin API

Upstream을 생성하려면 Admin API의 /upstreams 엔드포인트를 호출하세요.

curl -i -X POST http://localhost:8001/upstreams/ \
    --header "Accept: application/json" \
    --header "Content-Type: application/json" \
    --data '
    {
      "name": "example-upstream",
      "algorithm": "round-robin"
    }
    '

Konnect API

Upstream을 생성하려면 Konnect 컨트롤 플레인 config API의 /upstreams 엔드포인트를 호출하세요.

curl -X POST https://{region}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/upstreams/ \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer $KONNECT_TOKEN" \
    --data '
    {
      "name": "example-upstream",
      "algorithm": "round-robin"
    }
    '

다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:

  • region: Kong Konnect가 호스팅되고 운영되는 지리적 지역이에요.

  • KONNECT_TOKEN: Konnect 계정과 연결된 여러분의 개인 액세스 토큰(PAT)이에요.

  • controlPlaneId: 컨트롤 플레인의 id예요.

지역별 URL과 개인 액세스 토큰에 대해 자세히 알아보려면 Konnect Control Planes Config API 레퍼런스를 확인하세요.

KIC

Kong Ingress Controller는 Kubernetes 클러스터에서 발견된 엔드포인트를 기반으로 Upstream을 자동으로 구성해요.

Terraform

사전 조건: 개인 액세스 토큰 구성
terraform {
  required_providers {
    konnect = {
      source  = "kong/konnect"
    }
  }
}

provider "konnect" {
  personal_access_token = "$KONNECT_TOKEN"
  server_url            = "https://us.api.konghq.com/"
}

Terraform 구성에 다음을 추가하세요:

resource "konnect_gateway_upstream" "my_upstream" {
  algorithm = "round-robin"

  control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
}

UI

다음은 기본 구성으로 새 Upstream을 생성하는 방법이에요:

  1. Gateway 인스턴스로 이동하세요:
  • Konnect 사이드바에서 API Gateway > Gateways를 클릭한 다음 컨트롤 플레인을 선택하세요.
  • Kong Manager에서 Workspace를 선택하세요.
  1. Upstreams로 이동하세요:
  • Konnect에서 컨트롤 플레인 안에 있는 Upstreams 탭을 클릭하세요.
  • Kong Manager에서 사이드바의 Upstreams를 열어요.
  1. New upstream을 클릭하세요.
  2. Upstream의 고유한 이름을 입력하세요. 예를 들어: example-upstream.
  3. Save를 클릭하세요.

스키마

{
  "additionalProperties": false,
  "description": "The upstream object represents a virtual hostname and can be used to loadbalance incoming requests over multiple services (targets). So for example an upstream named `service.v1.xyz` for a Service object whose `host` is `service.v1.xyz`. Requests for this Service would be proxied to the targets defined within the upstream. An upstream also includes a [health checker][healthchecks], which is able to enable and disable targets based on their ability or inability to serve requests. The configuration for the health checker is stored in the upstream object, and applies to all of its targets.",
  "example": {
    "algorithm": "round-robin",
    "hash_fallback": "none",
    "hash_on": "none",
    "hash_on_cookie_path": "/",
    "healthchecks": {
      "active": {
        "concurrency": 10,
        "healthy": {
          "http_statuses": [
            200,
            302
          ],
          "interval": 0,
          "successes": 0
        },
        "http_path": "/",
        "https_verify_certificate": true,
        "timeout": 1,
        "type": "http",
        "unhealthy": {
          "http_failures": 0,
          "http_statuses": [
            429,
            404,
            500,
            501,
            502,
            503,
            504,
            505
          ],
          "interval": 0,
          "tcp_failures": 0,
          "timeouts": 0
        }
      },
      "passive": {
        "healthy": {
          "http_statuses": [
            200,
            201,
            202,
            203,
            204,
            205,
            206,
            207,
            208,
            226,
            300,
            301,
            302,
            303,
            304,
            305,
            306,
            307,
            308
          ],
          "successes": 0
        },
        "type": "http",
        "unhealthy": {
          "http_failures": 0,
          "http_statuses": [
            429,
            500,
            503
          ],
          "tcp_failures": 0,
          "timeouts": 0
        }
      },
      "threshold": 0
    },
    "id": "6eed5e9c-5398-4026-9a4c-d48f18a2431e",
    "name": "api.example.internal",
    "slots": 10000
  },
  "properties": {
    "algorithm": {
      "default": "round-robin",
      "description": "Which load balancing algorithm to use.",
      "enum": [
        "consistent-hashing",
        "latency",
        "least-connections",
        "round-robin",
        "sticky-sessions"
      ],
      "nullable": true,
      "type": "string"
    },
    "client_certificate": {
      "description": "If set, the certificate to be used as client certificate while TLS handshaking to the upstream server.",
      "nullable": true,
      "properties": {
        "id": {
          "type": "string"
        }
      },
      "type": "object",
      "x-foreign": true
    },
    "created_at": {
      "description": "Unix epoch when the resource was created.",
      "nullable": true,
      "type": "integer"
    },
    "hash_fallback": {
      "default": "none",
      "description": "What to use as hashing input if the primary `hash_on` does not return a hash (eg. header is missing, or no Consumer identified). Not available if `hash_on` is set to `cookie`.",
      "enum": [
        "consumer",
        "cookie",
        "header",
        "ip",
        "none",
        "path",
        "query_arg",
        "uri_capture"
      ],
      "nullable": true,
      "type": "string"
    },
    "hash_fallback_header": {
      "description": "The header name to take the value from as hash input. Only required when `hash_fallback` is set to `header`.",
      "nullable": true,
      "type": "string"
    },
    "hash_fallback_query_arg": {
      "description": "The name of the query string argument to take the value from as hash input. Only required when `hash_fallback` is set to `query_arg`.",
      "minLength": 1,
      "nullable": true,
      "type": "string"
    },
    "hash_fallback_uri_capture": {
      "description": "The name of the route URI capture to take the value from as hash input. Only required when `hash_fallback` is set to `uri_capture`.",
      "minLength": 1,
      "nullable": true,
      "type": "string"
    },
    "hash_on": {
      "default": "none",
      "description": "What to use as hashing input. Using `none` results in a weighted-round-robin scheme with no hashing.",
      "enum": [
        "consumer",
        "cookie",
        "header",
        "ip",
        "none",
        "path",
        "query_arg",
        "uri_capture"
      ],
      "nullable": true,
      "type": "string"
    },
    "hash_on_cookie": {
      "description": "The cookie name to take the value from as hash input. Only required when `hash_on` or `hash_fallback` is set to `cookie`. If the specified cookie is not in the request, Kong will generate a value and set the cookie in the response.",
      "nullable": true,
      "type": "string"
    },
    "hash_on_cookie_path": {
      "default": "/",
      "description": "The cookie path to set in the response headers. Only required when `hash_on` or `hash_fallback` is set to `cookie`.",
      "nullable": true,
      "type": "string"
    },
    "hash_on_header": {
      "description": "The header name to take the value from as hash input. Only required when `hash_on` is set to `header`.",
      "nullable": true,
      "type": "string"
    },
    "hash_on_query_arg": {
      "description": "The name of the query string argument to take the value from as hash input. Only required when `hash_on` is set to `query_arg`.",
      "minLength": 1,
      "nullable": true,
      "type": "string"
    },
    "hash_on_uri_capture": {
      "description": "The name of the route URI capture to take the value from as hash input. Only required when `hash_on` is set to `uri_capture`.",
      "minLength": 1,
      "nullable": true,
      "type": "string"
    },
    "healthchecks": {
      "default": {
        "active": {
          "concurrency": 10,
          "healthy": {
            "http_statuses": [
              200,
              302
            ],
            "interval": 0,
            "successes": 0
          },
          "http_path": "/",
          "https_verify_certificate": true,
          "timeout": 1,
          "type": "http",
          "unhealthy": {
            "http_failures": 0,
            "http_statuses": [
              429,
              404,
              500,
              501,
              502,
              503,
              504,
              505
            ],
            "interval": 0,
            "tcp_failures": 0,
            "timeouts": 0
          }
        },
        "passive": {
          "healthy": {
            "http_statuses": [
              200,
              201,
              202,
              203,
              204,
              205,
              206,
              207,
              208,
              226,
              300,
              301,
              302,
              303,
              304,
              305,
              306,
              307,
              308
            ],
            "successes": 0
          },
          "type": "http",
          "unhealthy": {
            "http_failures": 0,
            "http_statuses": [
              429,
              500,
              503
            ],
            "tcp_failures": 0,
            "timeouts": 0
          }
        }
      },
      "description": "The array of healthchecks.",
      "nullable": true,
      "properties": {
        "active": {
          "default": {
            "concurrency": 10,
            "healthy": {
              "http_statuses": [
                200,
                302
              ],
              "interval": 0,
              "successes": 0
            },
            "http_path": "/",
            "https_verify_certificate": true,
            "timeout": 1,
            "type": "http",
            "unhealthy": {
              "http_failures": 0,
              "http_statuses": [
                429,
                404,
                500,
                501,
                502,
                503,
                504,
                505
              ],
              "interval": 0,
              "tcp_failures": 0,
              "timeouts": 0
            }
          },
          "properties": {
            "concurrency": {
              "default": 10,
              "maximum": 2147483648.0,
              "minimum": 1,
              "type": "integer"
            },
            "headers": {
              "additionalProperties": {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "description": "A map of header names to arrays of header values.",
              "type": "object"
            },
            "healthy": {
              "default": {
                "http_statuses": [
                  200,
                  302
                ],
                "interval": 0,
                "successes": 0
              },
              "properties": {
                "http_statuses": {
                  "default": [
                    200,
                    302
                  ],
                  "items": {
                    "maximum": 999,
                    "minimum": 100,
                    "type": "integer"
                  },
                  "type": "array"
                },
                "interval": {
                  "default": 0,
                  "maximum": 65535,
                  "minimum": 0,
                  "type": "number"
                },
                "successes": {
                  "default": 0,
                  "maximum": 254,
                  "minimum": 0,
                  "type": "integer"
                }
              },
              "type": "object"
            },
            "http_path": {
              "default": "/",
              "description": "A string representing a URL path, such as /path/to/resource. Must start with a forward slash (/) and must not contain empty segments (i.e., two consecutive forward slashes).",
              "type": "string"
            },
            "https_sni": {
              "description": "A string representing an SNI (server name indication) value for TLS.",
              "type": "string"
            },
            "https_verify_certificate": {
              "default": true,
              "type": "boolean"
            },
            "timeout": {
              "default": 1,
              "maximum": 65535,
              "minimum": 0,
              "type": "number"
            },
            "type": {
              "default": "http",
              "enum": [
                "grpc",
                "grpcs",
                "http",
                "https",
                "tcp"
              ],
              "type": "string"
            },
            "unhealthy": {
              "default": {
                "http_failures": 0,
                "http_statuses": [
                  429,
                  404,
                  500,
                  501,
                  502,
                  503,
                  504,
                  505
                ],
                "interval": 0,
                "tcp_failures": 0,
                "timeouts": 0
              },
              "properties": {
                "http_failures": {
                  "default": 0,
                  "maximum": 254,
                  "minimum": 0,
                  "type": "integer"
                },
                "http_statuses": {
                  "default": [
                    429,
                    404,
                    500,
                    501,
                    502,
                    503,
                    504,
                    505
                  ],
                  "items": {
                    "maximum": 999,
                    "minimum": 100,
                    "type": "integer"
                  },
                  "type": "array"
                },
                "interval": {
                  "default": 0,
                  "maximum": 65535,
                  "minimum": 0,
                  "type": "number"
                },
                "tcp_failures": {
                  "default": 0,
                  "maximum": 254,
                  "minimum": 0,
                  "type": "integer"
                },
                "timeouts": {
                  "default": 0,
                  "maximum": 254,
                  "minimum": 0,
                  "type": "integer"
                }
              },
              "type": "object"
            }
          },
          "type": "object"
        },
        "passive": {
          "default": {
            "healthy": {
              "http_statuses": [
                200,
                201,
                202,
                203,
                204,
                205,
                206,
                207,
                208,
                226,
                300,
                301,
                302,
                303,
                304,
                305,
                306,
                307,
                308
              ],
              "successes": 0
            },
            "type": "http",
            "unhealthy": {
              "http_failures": 0,
              "http_statuses": [
                429,
                500,
                503
              ],
              "tcp_failures": 0,
              "timeouts": 0
            }
          },
          "properties": {
            "healthy": {
              "default": {
                "http_statuses": [
                  200,
                  201,
                  202,
                  203,
                  204,
                  205,
                  206,
                  207,
                  208,
                  226,
                  300,
                  301,
                  302,
                  303,
                  304,
                  305,
                  306,
                  307,
                  308
                ],
                "successes": 0
              },
              "properties": {
                "http_statuses": {
                  "default": [
                    200,
                    201,
                    202,
                    203,
                    204,
                    205,
                    206,
                    207,
                    208,
                    226,
                    300,
                    301,
                    302,
                    303,
                    304,
                    305,
                    306,
                    307,
                    308
                  ],
                  "items": {
                    "maximum": 999,
                    "minimum": 100,
                    "type": "integer"
                  },
                  "type": "array"
                },
                "successes": {
                  "default": 0,
                  "maximum": 254,
                  "minimum": 0,
                  "type": "integer"
                }
              },
              "type": "object"
            },
            "type": {
              "default": "http",
              "enum": [
                "grpc",
                "grpcs",
                "http",
                "https",
                "tcp"
              ],
              "type": "string"
            },
            "unhealthy": {
              "default": {
                "http_failures": 0,
                "http_statuses": [
                  429,
                  500,
                  503
                ],
                "tcp_failures": 0,
                "timeouts": 0
              },
              "properties": {
                "http_failures": {
                  "default": 0,
                  "maximum": 254,
                  "minimum": 0,
                  "type": "integer"
                },
                "http_statuses": {
                  "default": [
                    429,
                    500,
                    503
                  ],
                  "items": {
                    "maximum": 999,
                    "minimum": 100,
                    "type": "integer"
                  },
                  "type": "array"
                },
                "tcp_failures": {
                  "default": 0,
                  "maximum": 254,
                  "minimum": 0,
                  "type": "integer"
                },
                "timeouts": {
                  "default": 0,
                  "maximum": 254,
                  "minimum": 0,
                  "type": "integer"
                }
              },
              "type": "object"
            }
          },
          "type": "object"
        },
        "threshold": {
          "default": 0,
          "maximum": 100,
          "minimum": 0,
          "type": "number"
        }
      },
      "type": "object"
    },
    "host_header": {
      "description": "The hostname to be used as `Host` header when proxying requests through Kong.",
      "nullable": true,
      "type": "string"
    },
    "id": {
      "description": "A string representing a UUID (universally unique identifier).",
      "nullable": true,
      "type": "string"
    },
    "name": {
      "description": "This is a hostname, which must be equal to the `host` of a Service.",
      "type": "string"
    },
    "slots": {
      "default": 10000,
      "description": "The number of slots in the load balancer algorithm. If `algorithm` is set to `round-robin`, this setting determines the maximum number of slots. If `algorithm` is set to `consistent-hashing`, this setting determines the actual number of slots in the algorithm. Accepts an integer in the range `10`-`65536`.",
      "maximum": 65536,
      "minimum": 10,
      "nullable": true,
      "type": "integer"
    },
    "sticky_sessions_cookie": {
      "description": "The cookie name to keep sticky sessions.",
      "nullable": true,
      "type": "string"
    },
    "sticky_sessions_cookie_path": {
      "default": "/",
      "description": "A string representing a URL path, such as /path/to/resource. Must start with a forward slash (/) and must not contain empty segments (i.e., two consecutive forward slashes).",
      "nullable": true,
      "type": "string"
    },
    "tags": {
      "description": "An optional set of strings associated with the Upstream for grouping and filtering.",
      "items": {
        "description": "A string representing a tag.",
        "type": "string"
      },
      "nullable": true,
      "type": "array"
    },
    "updated_at": {
      "description": "Unix epoch when the resource was last updated.",
      "nullable": true,
      "type": "integer"
    },
    "use_srv_name": {
      "default": false,
      "description": "If set, the balancer will use SRV hostname(if DNS Answer has SRV record) as the proxy upstream `Host`.",
      "nullable": true,
      "type": "boolean"
    }
  },
  "required": [
    "name"
  ],
  "type": "object"
}

번역할 문서 조각이 아직 첨부되지 않았어요. Kong 문서 내용(마크다운)을 보내주시면 규칙에 따라 바로 번역할게요.

자주 묻는 질문(FAQ)

  • sticky-sessions 알고리즘에서 쿠키는 만료되나요? 아니요, 세션 쿠키라서 클라이언트 세션이 끝날 때 함께 만료돼요.

  • sticky-sessions 쿠키는 어디에 저장되나요? 클라이언트에 저장돼요. Kong Gateway는 쿠키 값을 서버 측에 저장하지 않아요. 브라우저(또는 사용자 에이전트)가 쿠키를 자동으로 저장하고 전송하는 일을 담당해요.

  • 스티키 Target이 제거되면 어떻게 되나요? 새로운 Target이 선택되고 새 쿠키가 생성돼요.

  • 두 업스트림이 같은 쿠키 이름과 경로를 사용하면 어떻게 되나요? 업스트림이 같은 Target을 공유한다면 클라이언트는 계속 해당 Target으로 라우팅돼요. 그렇지 않으면 쿠키가 덮어써지고 새로운 Target으로 라우팅이 시작돼요.

  • sticky-sessions는 일관성 해싱(consistent hashing)과 어떻게 다른가요? 스티키 세션은 클라이언트 측 쿠키를 사용해 특정 Target과의 친화성을 유지하기 때문에, Target이 바뀌어도 일관된 라우팅이 유지돼요. 일관성 해싱은 해시 입력값(IP나 헤더 값 등)에 의존하고, Target이 추가되거나 제거되면 재밸런싱이 일어날 수 있지만 세션 고정성은 보장되지 않아요.

관련 리소스

더 알아보기 (Learn more)

  • 업스트림이 실제로 트래픽을 전달하는 대상인 타깃 엔티티의 상세 문서예요 — Targets
  • 업스트림과 함께 구성되는 게이트웨이 서비스 엔티티를 이해하면 둘의 연관 관계가 더 명확해져요 — Gateway Services
  • 라운드 로빈, 일관된 해싱, 최소 연결 등 로드 밸런싱 알고리즘을 깊이 있게 다뤄요 — load balancing algorithms
  • 타깃 상태를 능동적으로 점검하는 활성 헬스 체크 설정 방법을 설명해요 — health check
  • 로드 밸런싱이 필요 없을 때 라우트의 host 헤더로 요청을 라우팅하는 방법을 참고할 수 있어요 — Route
  • 장애 상황에서 백업 타깃으로 요청을 우회시키는 실전 시나리오를 다룬 가이드예요 — Route requests to backup Targets during failures