게시 2026-11-21Published 2026-11-21Container읽는 시간 23분23 min read직접 테스트: 서울 리전의 Amazon EKS 환경 하나, 반복 횟수는 표마다 표기Tested first-hand: One Amazon EKS environment in the Seoul Region, the number of runs is given with each table

OpenWeight on AWS GPU 2부: 두 모델을 서빙하는 구조와 Amazon EKS 최적화OpenWeight on AWS GPU, Part 2: The architecture for serving two models and Amazon EKS optimizations

오픈 웨이트 모델 두 개를 Amazon EKS에서 직접 서빙하려면 어떤 구성 요소가 필요하고 어디를 최적화해야 할까요? OpenWeight on AWS GPU 시리즈의 2부인 이 글은 전체 구조를 앱, 게이트웨이, 서빙, 모델과 이미지 공급, 노드 관리, 관측의 6개 계층으로 나눠 설명합니다. Amazon EKS 쪽에서 적용한 최적화 4가지로 콜드 스타트는 394초에서 260초가 됐습니다. 배치 부하 중 상담 요청의 첫 토큰까지의 시간은 중앙값 30.9초에서 0.19초가 됐고 잠든 모델은 3.66초 만에 복귀했습니다.Which components does it take to serve two open-weight models yourself on Amazon EKS, and where should you optimize? This post, Part 2 of the OpenWeight on AWS GPU series, explains the whole architecture in six layers: app, gateway, serving, model and image supply, node management and observability. With four optimizations on the Amazon EKS side, the cold start went from 394 s to 260 s. Under batch load the median time to first token of interactive requests went from 30.9 s to 0.19 s, and a sleeping model was back in 3.66 s.

#Amazon EKS#vLLM#LLM inference#GPU#Karpenter#Gateway API Inference Extension#Open-weight models

6개 계층으로 나눈 전체 구조

오픈 웨이트 모델(가중치가 공개되어 내려받아 직접 실행할 수 있는 모델)을 직접 서빙하는 일은 GPU 노드에 추론 엔진을 올리는 것으로 끝나지 않습니다. 요청을 받는 입구, 모델을 고르는 라우팅, 가중치를 GPU까지 옮기는 경로, 노드를 만들고 회수하는 규칙이 함께 있어야 합니다. OpenWeight on AWS GPU(OW on GPU)는 이 구성을 Amazon Elastic Kubernetes Service(Amazon EKS)에서 처음부터 만들어 보는 시리즈입니다. 예로 드는 환경은 오픈 소스 추론 엔진 vLLM으로 Gemma 4 31B와 Qwen3.8-27B를 함께 서빙하며 코드는 ow-on-gpu 저장소에 있습니다.

2부인 이 글은 그 환경의 구조를 설명합니다. 먼저 전체 구성을 6개 계층으로 나눠 구성 요소마다 맡은 일을 봅니다. 이어서 Amazon EKS 쪽에서 적용한 최적화 4가지를 측정한 값과 함께 정리합니다.

1부는 API 호출 한 건이 이 구조를 지나는 8개 단계를 따라가고 3부는 같은 환경을 10개 단계로 구축합니다. 본문의 값은 2026년 11월 14일과 15일에 서울 리전(ap-northeast-2)에서 측정했고 반복 횟수는 표마다 적었습니다. Kubernetes와 AWS의 기본 개념(파드, Deployment, IAM 역할)을 알고 LLM 서빙을 처음 구성하는 분을 생각하고 썼습니다.

그림 1은 전체 구조를 한 장에 그린 것입니다. 이 글의 각 챕터는 이 그림의 한 부분을 확대해 설명합니다.

브라우저의 요청이 CloudFront, 내부 ALB, BFF, 게이트웨이를 지나 GPU 노드의 Gemma 4 31B와 Qwen3.8-27B에 이르는 경로와, Hugging Face의 체크포인트를 적재 Job이 S3 모델 버킷에 올리고 GPU 노드가 그 버킷과 이미지 레지스트리에서 가중치, compile 캐시, 컨테이너 이미지를 받는 공급 경로를 한 장에 그린 구조도. 아래쪽에는 모델 적재부터 추론 요청까지의 6개 단계, BFF의 모델 결정 순서, 구간별 측정값, 경계별 접근 제한을 정리했다
그림 1. 전체 구조 한눈에 보기. 실선은 요청과 데이터, 점선은 로그인과 권한, 지표의 흐름입니다. 번호 0에서 4는 모델과 이미지가 GPU 노드에 올라가는 순서이고 5는 추론 요청입니다

계층마다 맡은 일

환경은 서울 리전의 Amazon EKS 1.37 클러스터 하나입니다. 구성 요소가 많아 보여도 맡은 일로 묶으면 6개 계층입니다. 계층마다 바꿀 수 있는 설정과 측정할 지표가 다르므로 이 구분을 먼저 익혀 두면 뒤의 챕터를 읽기 쉽습니다.

계층구성 요소맡은 일
앱Amazon CloudFront, AWS WAF, Amazon Cognito, 내부 ALB, BFF 파드 2개정적 페이지 제공, 속도 제한, 로그인 토큰 검증, 모델과 우선순위 결정, 도구 실행
게이트웨이agentgateway 파드 2개, 모델별 EPP요청 본문의 model 값으로 모델별 풀 선택, 노출 경로 제한, 포화 시 배치 요청 거절
서빙vLLM 파드 2개(Gemma 4 31B, Qwen3.8-27B), Strands Decider 12B추론, 요청 처리 순서 결정, 모델 판단
모델과 이미지 공급Amazon S3 모델 버킷, 적재 Job, 캐시 게시 Job가중치와 compile 캐시를 GPU 노드까지 전달
노드 관리Karpenter NodePool 6개, 관리형 노드 그룹 1개워크로드별 노드 생성과 회수
관측Prometheus agent, Amazon Managed Service for PrometheusvLLM, EPP, 게이트웨이의 지표 수집과 저장

표 1. 계층별 구성 요소와 맡은 일

그림 1의 왼쪽은 요청 경로입니다. 요청은 Amazon CloudFront, 내부 Application Load Balancer(ALB), BFF, 게이트웨이를 차례로 지나 vLLM에 도착합니다. BFF(Backend for Frontend)는 화면과 모델 사이에서 로그인을 확인하고 요청을 어느 모델로 보낼지 정하는 서비스입니다. 인터넷에 열린 곳은 CloudFront 하나이고 나머지는 모두 VPC 안에 있습니다.

그림의 오른쪽은 공급 경로입니다. 모델의 가중치와 컨테이너 이미지가 GPU 노드에 올라가는 길이고 번호 0에서 4의 순서로 진행됩니다. 요청 경로가 응답 속도를 정한다면 공급 경로는 새 파드가 요청을 받기까지의 시간을 정합니다.

구조도에는 추론 모델 말고도 요청을 돕는 구성 요소가 둘 있습니다. Strands Decider 12B는 g6e.xlarge 노드 한 대에서 실행하고 게이트웨이의 /decide 경로로 호출합니다. InferencePool을 사용하지 않고 HTTPRoute가 Service로 바로 보냅니다. 이 환경은 2026년 11월 24일에 Decider를 v1의 2B 모델(g6.xlarge)에서 Strands Decider v2의 12B 모델로 바꿨습니다. 요청과 응답의 형식은 v1과 같아 BFF는 수정하지 않았습니다. Amazon Bedrock AgentCore Web Search는 BFF가 실행하는 도구여서 게이트웨이와 vLLM의 구성은 바꾸지 않았습니다. 두 구성 요소가 요청마다 하는 일과 측정값은 1부에서, Decider 12B의 서빙 이미지를 준비하는 절차는 3부에서 다룹니다.

두 모델의 업무 배정과 데이터 정책

모델을 둘로 나눈 기준은 업무와 데이터입니다. Gemma 4 31B는 고객 요청을, Qwen3.8-27B는 내부 업무를 맡습니다.

업무모델우선순위
상담 챗봇(함수 호출로 주문 조회)Gemma 4 31Binteractive
상품 설명 다국어 번역, 리뷰 요약Gemma 4 31Bbatch
상품 이미지 속성 추출, 문서 OCRQwen3.8-27Binteractive 또는 batch
사내 코딩 에이전트Qwen3.8-27Binteractive

표 2. 업무와 모델 배정. interactive는 사용자가 기다리는 요청이고 batch는 나중에 처리해도 되는 요청입니다

데이터 정책은 한 줄입니다. 개인정보가 든 요청은 Gemma 4 31B로만 보냅니다. 주민등록번호나 카드번호처럼 형식이 정해진 정보는 BFF의 규칙이 먼저 거르고, 형식이 없는 경우의 판단은 Strands Decider 12B가 돕습니다.

01

워크로드마다 따로 두는 노드

관리형 노드 그룹 1개와 NodePool 6개

이 챕터는 어떤 워크로드가 어떤 노드에 올라가는지를 설명합니다. GPU 노드는 비싸고 종류가 적어서, 무엇을 GPU 노드에 올리고 무엇을 올리지 않을지를 노드 단위로 나눠 두어야 합니다. Karpenter 자신이 실행될 노드는 Karpenter가 뜨기 전부터 필요하므로 관리형 노드 그룹으로 만듭니다.

노드 묶음인스턴스올라가는 워크로드격리와 한도
관리형 노드 그룹 addonsm7g.large 2대Karpenter, CoreDNS, AWS Load Balancer ControllerCriticalAddonsOnly taint
NodePool systemc7i-flex.xlarge 2대게이트웨이, EPP, 깨우기 API, Prometheus agent, 적재 JobCPU 32개 한도
NodePool appc7g.large 2대BFF 파드 2개ow-on-gpu/app taint, CPU 8개 한도
NodePool gemma-odg6e.4xlarge 1대Gemma 4 31Bnvidia.com/gpu taint, GPU 1장 한도
NodePool qwen-odg6e.4xlarge 1대Qwen3.8-27Bnvidia.com/gpu taint, GPU 1장 한도
NodePool deciderg6e.xlarge 1대Strands Decider 12Bnvidia.com/gpu taint, GPU 1장 한도
NodePool bench측정할 때만 생성부하 발생기 Jobow-on-gpu/bench taint, CPU 16개 한도

표 3. 노드 묶음과 워크로드(인스턴스는 2026년 11월 24일 기준). Karpenter가 만드는 노드는 모두 On-Demand이고 워크로드는 VPC의 프라이빗 서브넷에 둡니다

게이트웨이와 EPP는 두 모델이 함께 지나는 길목이라 system 노드 2대를 서로 다른 가용 영역에 두고 복제본을 나눠 올렸습니다. BFF는 Graviton 노드를, 부하 발생기는 측정할 때만 뜨는 노드를 따로 사용합니다. 측정 부하가 서빙 경로의 파드와 CPU를 다투지 않게 하려는 구분입니다.

모델마다 한 대로 묶는 GPU NodePool

GPU NodePool은 모델마다 하나입니다. 아래는 Gemma용이고 Qwen용은 이름만 다릅니다.

yaml
# k8s/base/nodepools.yaml에서 발췌
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
  name: gemma-od
spec:
  template:
    spec:
      nodeClassRef:
        group: karpenter.k8s.aws
        kind: EC2NodeClass
        name: vllm
      requirements:
        - key: node.kubernetes.io/instance-type
          operator: In
          values: ["g6e.4xlarge"]
        - key: karpenter.sh/capacity-type
          operator: In
          values: ["on-demand"]
      taints:
        - key: nvidia.com/gpu
          value: "true"
          effect: NoSchedule
  limits:
    nvidia.com/gpu: 1
  disruption:
    consolidationPolicy: WhenEmpty
    consolidateAfter: 30m

이 매니페스트에서 볼 설정은 3곳입니다.

  • limits의 nvidia.com/gpu: 1은 이 NodePool이 만드는 GPU를 한 장으로 묶습니다. Karpenter 문서에 따르면 한도를 넘은 NodePool은 새 노드를 만들지 않습니다. 복제본 수를 실수로 올려도 GPU 노드가 늘지 않습니다.
  • taints는 이 taint를 허용하지 않는 파드가 GPU 노드에 스케줄되지 않게 합니다. vLLM 파드는 같은 키의 toleration과 karpenter.sh/nodepool nodeSelector로 자기 NodePool을 고릅니다.
  • consolidationPolicy: WhenEmpty는 워크로드 파드가 없는 노드만 30분 뒤에 회수합니다. 파드를 다시 띄우는 동안 노드가 남아 있어야 뒤에서 볼 웜 재시작이 됩니다.

가용 영역 조건은 두지 않아 Karpenter가 용량이 있는 영역을 고릅니다. 조회 시점에 g6e.4xlarge는 서울 리전의 가용 영역 4곳 가운데 ap-northeast-2a와 ap-northeast-2b에서만 제공됐습니다.

g6e.4xlarge와 FP8 체크포인트

g6e.4xlarge에는 NVIDIA L40S가 한 장 있습니다. vCPU 16개, 메모리 128GiB, 인스턴스 스토어 600GB이고 GPU 메모리는 제품 페이지 표기로 48GB입니다. vLLM의 기동 로그에 기록된 값은 44.39GiB였습니다.

GPU 세대가 체크포인트의 형식을 정합니다. FP8은 가중치를 8비트 부동소수점으로 줄인 양자화 형식입니다. L40S는 Ada 세대(compute capability 8.9)이고 vLLM 문서의 양자화 지원표에서 llm-compressor FP8은 Ada와 Hopper에서 지원됩니다. 그래서 두 모델 모두 FP8-dynamic 체크포인트를 사용했습니다.

모델체크포인트가중치 파일GPU에 올라간 크기
Gemma 4 31BRedHatAI/gemma-4-31B-it-FP8-dynamic33.27GB30.63GiB
Qwen3.8-27BAzatAI/Qwen3.8-27B-FP8-dynamic36.78GB34.39GiB

표 4. 두 모델의 체크포인트. 파일 크기는 1GB = 10^9바이트 기준이고 GPU에 올라간 크기는 vLLM 로그의 Model loading took 값입니다

Qwen3.8-27B에는 가중치가 5.9GB 작은 공식 block FP8 체크포인트도 있습니다. 다만 vLLM v0.33.0 소스에서 block FP8용 CUTLASS 커널은 compute capability 9.0 이상에서만 지원됩니다. 그래서 문서가 Ada 지원을 명시한 per-channel 체크포인트를 골랐고 L40S에서 block FP8이 어떻게 동작하는지는 확인하지 않았습니다. 다른 GPU를 사용한다면 체크포인트를 고르기 전에 그 세대가 지원하는 양자화 형식부터 확인하는 것을 권고합니다.

02

모델과 이미지가 GPU 노드에 오는 경로

S3에 한 번 올리고 S3에서만 읽는 가중치

이 챕터는 30GiB가 넘는 가중치가 어디에 있고 어떤 권한으로 GPU 노드에 오는지를 설명합니다. 원칙은 하나입니다. 서빙 파드는 Hugging Face에서 내려받지 않고 Amazon Simple Storage Service(Amazon S3) 버킷에서만 읽습니다. 외부 저장소의 속도와 가용성이 서빙 파드의 시작에 영향을 주지 않게 하려는 구성입니다.

적재 Job이 리비전 해시로 고정한 저장소 3개(Gemma 4 31B, Qwen3.8-27B, Decider 12B)를 버킷에 올립니다. 파일을 받는 대로 s5cmd pipe로 올려 로컬 디스크에 쌓지 않고, 받으면서 계산한 해시를 Hugging Face가 알려 준 값과 비교합니다. 세 저장소를 합치면 객체 45개, 94.07GB입니다. 2026년 11월 14일의 첫 적재는 당시 사용하던 Decider v1과 그 기반 모델을 포함해 객체 73개, 74.90GB(69.8GiB)였고 전송과 검증에 491.4초 걸렸습니다. 2026년 11월 24일에 Decider 12B(객체 13개, 23.97GB)를 추가로 올리는 데는 314.9초 걸렸습니다. 버킷의 구조는 다음과 같이 나눴습니다.

text
s3://<bucket>/models/gemma-4-31B-it-FP8-dynamic/
s3://<bucket>/models/Qwen3.8-27B-FP8-dynamic/
s3://<bucket>/models/strands-decider-12B-gemma4-v2-2611/
s3://<bucket>/vllm-cache/v0.33.0-gemma4-31b-fp8-l40s/
s3://<bucket>/vllm-cache/v0.33.0-qwen38-27b-fp8-l40s/

models/에는 가중치가, vllm-cache/에는 뒤에서 설명할 compile 캐시가 들어갑니다. Decider 12B의 체크포인트는 어댑터를 병합한 전체 가중치를 담고 있어 기반 모델을 따로 올리지 않습니다.

권한은 EKS Pod Identity로 줍니다. AWS Identity and Access Management(IAM) 역할은 읽기와 쓰기로 나눴습니다. 읽기 역할은 서빙 파드의 ServiceAccount 3개(gemma, qwen, decider)에, 쓰기 역할은 적재 Job과 캐시 게시 Job에만 연결했습니다. 서빙 파드는 버킷에 아무것도 올리지 못하고 매니페스트에는 자격 증명이 없습니다. 버킷까지의 트래픽은 VPC의 S3 게이트웨이 엔드포인트를 지납니다.

GPU 노드의 디스크와 이미지

vLLM 이미지(vllm/vllm-openai:v0.33.0)는 9.74GB입니다. GPU 노드의 EC2NodeClass는 이 이미지를 받을 자리와 받는 시점을 정합니다.

yaml
# k8s/base/ec2nodeclasses.yaml에서 발췌(주석과 일부 필드 생략)
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
metadata:
  name: vllm
spec:
  amiSelectorTerms:
    - alias: al2023@v20261107
  instanceStorePolicy: RAID0
  userData: |
    #!/bin/bash
    systemd-run --unit=prepull-vllm --no-block /bin/bash -c '
      until ctr --namespace k8s.io version >/dev/null 2>&1; do sleep 1; done
      ctr --namespace k8s.io images pull docker.io/vllm/vllm-openai:v0.33.0
    '

amiSelectorTerms의 별칭은 EKS 최적화 AL2023 AMI의 릴리스를 고정하고 GPU 노드에는 NVIDIA 드라이버가 든 변형이 올라옵니다. instanceStorePolicy: RAID0은 인스턴스 스토어를 kubelet과 containerd의 저장 공간으로 사용하게 합니다. GPU 노드에서는 559GB가 마운트됐고 이미지가 여기에 저장됐습니다. userData의 스크립트는 노드가 뜨는 동안 이미지를 미리 받기 시작합니다. 이 사전 pull의 효과는 다음 챕터에서 봅니다.

가중치와 compile 캐시를 받는 vLLM 파드

Gemma의 Deployment에서 공급 경로와 관련된 부분만 옮겼습니다.

yaml
# k8s/gemma/deployment.yaml에서 발췌
      initContainers:
        - name: cache-restore
          image: vllm/vllm-openai:v0.33.0
          command: ["python3", "/scripts/cache-restore.py"]
          env:
            - name: CACHE_PREFIX
              value: vllm-cache/v0.33.0-gemma4-31b-fp8-l40s
      containers:
        - name: vllm
          image: vllm/vllm-openai:v0.33.0
          args:
            - s3://$(MODEL_BUCKET)/models/gemma-4-31B-it-FP8-dynamic
            - --load-format=runai_streamer
            - --gpu-memory-utilization=0.90
          env:
            - name: VLLM_CACHE_ROOT
              value: /vllm-cache
            - name: HF_HUB_OFFLINE
              value: "1"
      volumes:
        - name: vllm-cache
          hostPath:
            path: /var/cache/vllm

모델 인자가 s3:// 경로이고 로더가 runai_streamer입니다. vLLM 문서에 따르면 Run:ai Model Streamer는 텐서를 동시에 읽으면서 GPU 메모리로 스트리밍하는 라이브러리입니다. 가중치를 노드의 디스크에 먼저 내려받는 단계가 없습니다. HF_HUB_OFFLINE=1은 설정이 틀렸을 때 파드가 조용히 Hugging Face에서 받아 오는 일을 막습니다. initContainer cache-restore는 S3의 compile 캐시를 노드의 hostPath로 내려받습니다.

03

콜드 스타트 394초를 260초로 줄인 3가지 조치

4개 구간으로 나눠 측정한 결과

GPU 노드에서 서빙 파드를 새로 띄우면 요청을 받기까지 몇 분이 걸립니다. 노드를 줄였다 늘리거나 장애 뒤에 복구할 때 이 시간이 그대로 서비스 공백이 됩니다. 새 노드에서 시작하는 경우를 콜드 스타트(Cold start), 같은 노드에서 파드만 다시 띄우는 경우를 웜 재시작(Warm restart)이라고 부르겠습니다.

파드 생성부터 Ready까지의 시간을 4개 구간과 나머지(기타)로 나눴습니다. 구간마다 기다리는 대상이 다르므로 줄이는 방법도 다릅니다. 기준 구성은 최적화를 적용하기 전의 구성이고 최적화 구성이 지금 서빙에 사용하는 구성입니다.

구간측정 근거기준 구성최적화 구성기준최적화
노드 프로비저닝NodeClaim 생성부터 노드의 Ready까지Karpenter가 g6e.4xlarge를 만듦같음55.071.0
이미지 pullkubelet의 Pulled 이벤트파드가 스케줄된 뒤 받기 시작노드가 뜨는 동안 받기 시작111.171.0
가중치 로드vLLM 로그의 Model loading tookMountpoint for Amazon S3로 마운트한 경로를 기본 로더로 읽음s3:// 경로를 runai_streamer로 스트리밍59.619.2
엔진 초기화vLLM 로그의 init engine ... tookcompile 캐시가 컨테이너 안에 생기고 파드와 함께 사라짐S3의 compile 캐시를 hostPath로 복원95.523.7
기타전체에서 위 4개 구간을 뺀 값72.775.1
합계파드 생성부터 Ready까지394260

표 5. Gemma 4 31B 콜드 스타트의 구간별 시간(초, 2026년 11월 14일, 구성마다 한 번). 로더를 뺀 엔진 플래그와 모델, vLLM 버전은 두 구성이 같습니다

시나리오Gemma 4 31BQwen3.8-27B
콜드 스타트, 기준 구성394초측정하지 않음
콜드 스타트, 최적화 구성260초290초
웜 재시작, 기준 구성214초측정하지 않음
웜 재시작, 최적화 구성86초123초

표 6. 시나리오별 파드 생성부터 Ready까지의 시간(2026년 11월 14일, 시나리오마다 한 번)

Gemma 4 31B의 콜드 스타트는 134초(34%), 웜 재시작은 128초(60%) 줄었습니다. 그림 2는 시나리오별 구간과 구간마다 적용한 조치를 함께 보여 줍니다.

콜드 스타트의 구간 분해와 최적화를 한 장에 정리한 인포그래픽. Gemma 4 31B의 파드 생성에서 Ready까지의 시간이 콜드 스타트는 394초에서 260초로, 웜 재시작은 214초에서 86초로 줄었고, 이미지 pull은 노드 부팅 중 사전 pull로 111.1초에서 71.0초, 가중치 로드는 runai_streamer로 59.6초에서 19.2초, 엔진 초기화는 compile 캐시 복원으로 95.5초에서 23.7초가 됐음을 시나리오별 막대와 조치 표로 보여 준다
그림 2. 콜드 스타트 4개 구간과 구간별 조치. Qwen3.8-27B는 최적화 구성만 측정했습니다

구간마다 다른 3가지 조치

이미지 사전 pull은 받는 시간을 줄이지 않고 받기 시작하는 시점을 당깁니다. 최적화 구성에서는 노드의 사용자 데이터가 containerd가 뜨자마자 받기 시작하고 kubelet은 진행 중인 다운로드를 이어받습니다. 새 노드가 자주 뜨는 환경에서 적용할 만합니다.

스트리밍 로더로 가중치 로드는 3.1배 빨라졌습니다. 웜 재시작에서도 59.1초와 19.6초여서 이 구간은 노드가 새것인지와 무관했습니다. 가중치를 S3에 두고 있다면 --load-format=runai_streamer와 s3:// 경로, Pod Identity 권한으로 적용합니다. Run:ai Model Streamer가 boto3의 자격 증명을 사용하도록 RUNAI_STREAMER_NO_BOTO3_SESSION=0을 함께 설정했습니다.

compile 캐시는 엔진 초기화를 95.5초에서 23.7초로 줄였습니다. vLLM은 요청을 받기 전에 torch.compile을 끝내므로 컴파일 시간이 시작 시간에 그대로 들어갑니다. 차이의 대부분이 이 컴파일입니다(61.0초에서 0.9초). 캐시는 두 곳에 둡니다. 노드의 hostPath에 두면 같은 노드에서 파드가 다시 뜰 때 남아 있고, S3에 게시해 두면 새 노드에서 initContainer가 복원합니다. Gemma 4 31B의 캐시는 객체 522개, 90.8MB였고 복원에 3.3초가 걸렸습니다.

캐시를 운영할 때 지킬 규칙이 하나 있습니다. S3 prefix 이름에 vLLM 버전, 모델, 정밀도, GPU를 넣고 하나라도 바뀌면 새 prefix로 다시 게시합니다. 2026년 11월 15일에 Qwen의 플래그 하나를 바꿔 띄웠을 때 기존 캐시가 맞지 않아 compile에 62.6초가 걸렸습니다.

최적화 뒤에 남은 것은 노드 프로비저닝과 기타이고 260초 가운데 146.1초입니다. 노드 프로비저닝은 같은 날에도 55초에서 118초까지 달랐습니다. 이 글의 값을 예상치로 사용하기보다 같은 근거(NodeClaim과 파드의 시각, kubelet의 Pulled 이벤트, vLLM 로그 두 줄)로 직접 측정하는 것을 권고합니다.

04

GPU 메모리가 정하는 동시 실행 수

가중치를 빼고 남는 KV 캐시

파드가 Ready가 된 뒤에는 GPU 한 장이 요청을 동시에 몇 건 실행하는지가 용량을 정합니다. 그 수를 정하는 것이 KV 캐시입니다. KV 캐시(Key-Value cache)는 이미 처리한 토큰의 계산 결과를 GPU 메모리에 보관해 다음 토큰을 만들 때 다시 계산하지 않게 하는 공간입니다. 실행 중인 요청마다 자리를 차지하므로 KV 캐시가 차면 다음 요청은 기다립니다.

vLLM은 --gpu-memory-utilization으로 정한 비율만큼 GPU 메모리를 사용하고 가중치와 실행에 필요한 메모리를 뺀 나머지를 KV 캐시로 미리 잡습니다.

text
KV 캐시 메모리 = GPU 메모리 × gpu-memory-utilization - 가중치와 비 torch 메모리 - 활성값 최대

Gemma: 44.39 × 0.90 - 31.13 - 3.45 = 5.37 GiB
Qwen:  44.39 × 0.90 - 34.74 - 2.76 = 2.45 GiB

48GB GPU에 30GiB대 체크포인트를 올리면 KV 캐시로 남는 메모리는 한 자릿수 GiB입니다. Qwen3.8-27B는 처음 값인 0.85에서 KV 캐시가 0.24GiB만 남아 엔진이 시작하지 못했고 0.90으로 올려서야 시작했습니다. 가중치가 GPU 메모리의 대부분을 차지하는 구성에서는 이 값이 시작 성공 여부까지 정합니다.

Gemma 4 31B는 KV 캐시에 들어가는 만큼 실행

이 환경의 SLO(서비스 수준 목표)는 두 가지입니다. TTFT(Time To First Token)는 요청을 보내고 첫 토큰을 받기까지의 시간이고 p99가 500ms 이하여야 합니다. ITL(Inter-Token Latency)은 스트리밍으로 오는 응답 Chunk 사이의 간격이고 p99가 50ms 이하여야 합니다. 부하는 게이트웨이를 거치지 않고 vLLM Service에 직접 보냈고 동시성을 1에서 64까지 7단계로 올렸습니다.

워크로드입력, 출력 토큰동시 실행 한도최대 출력 처리량TTFT p99 500ms 이하인 최대 동시성
S1 짧은 채팅256, 12845건447.0 tok/s8
S2 요약과 생성1,024, 25612건164.7 tok/s1
S3 분류512, 1624건114.7 tok/s4
S4 장문 RAG4,096, 2567건81.8 tok/s없음

표 7. Gemma 4 31B의 워크로드별 결과(2026년 11월 14일, 랜덤 토큰 프롬프트, 단계마다 한 번). 동시 실행 한도는 동시성 64에서 엔진이 실제로 실행한 요청 수입니다

GPU는 여러 요청을 묶어 함께 계산하므로 요청이 늘면 전체 처리량도 늘어납니다(Gemma 4 31B는 동시성 1에서 18.5 tok/s, 32에서 424.4 tok/s). 요청이 길수록 한 건이 KV 캐시를 많이 차지해 동시에 실행되는 수가 줄어듭니다. 한도에 닿은 뒤에는 동시성을 올려도 처리량이 늘지 않고 TTFT만 길어집니다. S2는 동시성 16, 32, 64에서 처리량이 163.6, 164.7, 164.0 tok/s로 같았고 TTFT p99는 19초, 38초, 91초로 늘었습니다.

ITL은 부하와 무관하게 기준을 넘었습니다. 요청을 하나씩 보낸 동시성 1에서도 ITL p99가 57.6ms에서 58.6ms였고 중앙값이 54.0ms였습니다. 토큰 하나를 만드는 54ms는 L40S에서 이 체크포인트가 내는 속도입니다. 부하를 줄여서 나아지는 것은 TTFT이고 ITL 기준을 지키려면 GPU나 체크포인트를 바꾸거나 기준을 다시 정해야 합니다.

Qwen3.8-27B의 동시 3건 한도와 MTP

Qwen3.8-27B는 부하를 올려도 요청을 동시에 3건만 실행했습니다. 원인은 MTP(Multi-Token Prediction)입니다. MTP는 모델의 예측 헤드로 다음 토큰 여러 개를 미리 추측하고 본 모델이 한 번에 검증해 요청 하나의 속도를 올리는 방식입니다. vLLM v0.33.0 소스의 블록 계산에 따르면 추측 토큰 3개가 요청마다 잡는 상태 블록을 4배로 늘립니다. 요청 하나가 13블록을 잡고 KV 캐시는 46블록이어서 3건에서 멈춥니다.

항목MTP 켬(추측 토큰 3개)MTP 끔
요청당 KV 캐시 블록134
KV 캐시2.45GiB, 46블록4.0GiB, 82블록
동시 실행 한도3건20건
요청 하나의 생성 속도(동시성 1)32.5 tok/s19.2 tok/s
최대 출력 처리량91.2 tok/s281.8 tok/s
TTFT p99 500ms 이하인 최대 동시성28

표 8. Qwen3.8-27B, S1에서 MTP를 켠 구성(2026년 11월 14일)과 끈 구성(2026년 11월 15일). 랜덤 토큰 프롬프트, 각각 한 번 측정

MTP는 요청 하나의 속도를 1.7배로 올리는 대신 동시 실행 수를 3으로 묶습니다. 그래서 선택 기준은 동시에 겹치는 요청 수입니다. 요청이 3건을 넘지 않는 업무라면 켜는 쪽이, 사내 코딩 에이전트처럼 4건 이상 겹치는 업무라면 끄는 쪽이 유리합니다. 랜덤 토큰 프롬프트로 한 번 측정한 값이므로 실제 워크로드에서는 추측이 맞는 비율에 따라 속도 차이가 달라집니다.

L40S의 GPU 메모리 배분과 동시 실행 결과를 4칸으로 정리한 인포그래픽. SLO는 TTFT p99 500ms 이하와 ITL p99 50ms 이하이고, 가중치와 활성값을 빼면 KV 캐시는 Gemma 4 31B에 5.37GiB, Qwen3.8-27B에 2.45GiB가 남으며, S1에서 Gemma는 동시성 64에서 45건을 실행해 447.0 tok/s까지 늘고 Qwen은 MTP를 켠 구성에서 3건에 묶여 85.0에서 91.2 tok/s에 머물고, MTP를 끄면 동시 실행 한도가 20건이 되는 대신 요청 하나의 속도가 32.5에서 19.2 tok/s로 줄어든다
그림 3. GPU 메모리 배분과 동시 실행. 3번 칸의 막대는 S1 짧은 채팅의 출력 처리량이고 분홍색 막대는 동시 실행 한도에 닿은 단계입니다

용량을 볼 때는 기동 로그의 KV 캐시 크기만 보지 않는 것을 권고합니다. 엔진 지표의 실행 중 요청 수(vllm:num_requests_running)와 KV 캐시 사용률(vllm:kv_cache_usage_perc)을 함께 봅니다. Qwen의 한도는 로그의 토큰 수로는 알 수 없었고 이 두 지표에서 드러났습니다.

05

본문의 model 값으로 풀을 고르는 게이트웨이

InferencePool, EPP, agentgateway

게이트웨이 계층은 요청을 모델에 맞는 vLLM 파드로 넘기는 층입니다. 모델이 둘이므로 엔드포인트도 둘로 나눌 수 있지만, 이 환경은 엔드포인트를 하나로 두고 게이트웨이가 요청마다 모델을 가립니다. 클라이언트와 BFF는 주소 하나만 알면 되고 모델을 늘릴 때는 경로 규칙만 더합니다.

Gateway API Inference Extension(GAIE)은 Kubernetes Gateway API에 추론 워크로드용 리소스를 더하는 프로젝트입니다. InferencePool은 같은 모델을 서빙하는 파드의 묶음이고 HTTPRoute의 백엔드가 됩니다. EPP(Endpoint Picker)는 풀 안에서 요청을 받을 파드를 고르는 구성 요소입니다. agentgateway는 이 리소스를 읽어 실제로 트래픽을 넘기는 게이트웨이 구현체입니다.

구성 요소버전이 환경에서 하는 일
Gateway API CRDv1.6.3Gateway, HTTPRoute
GAIE CRDv1.6.2InferencePool
llm-d-routerv1.0.0풀마다 EPP 2개, InferenceObjective
agentgatewayv1.7.0게이트웨이 파드 2개, 본문 기반 라우팅
AWS Load Balancer Controllerv3.6.3게이트웨이 앞의 내부 NLB, BFF 앞의 내부 ALB

표 9. 게이트웨이 계층의 구성 요소와 버전(2026년 11월 14일 기준)

GAIE v1.6.0 릴리스 노트에 따르면 이 버전부터 EPP와 InferenceObjective가 llm-d 프로젝트로 옮겨졌습니다. 그래서 InferencePool CRD만 GAIE에서 설치하고 EPP와 InferenceObjective는 llm-d-router에서 설치했습니다. 이 환경은 풀마다 vLLM 파드가 하나라서 EPP가 고를 대상이 하나뿐이고 EPP의 스케줄링 시간은 요청당 0.03ms였습니다. 여기서 EPP가 실제로 하는 일은 풀이 포화했는지 판단해 우선순위가 낮은 요청을 거절하는 것입니다.

헤더로 옮긴 model 값과 정확히 일치하는 경로

OpenAI 호환 API에서 모델 이름은 URL이 아닌 요청 본문에 있습니다. 경로와 헤더로 백엔드를 고르는 HTTPRoute만으로는 두 모델을 가를 수 없으므로 라우팅 전에 본문의 model 값을 헤더로 옮깁니다. agentgateway 문서에 따르면 이 일은 AgentgatewayPolicy 하나로 처리합니다.

yaml
# k8s/gateway/gateway.yaml에서 발췌(주석 생략)
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayPolicy
metadata:
  name: model-routing
spec:
  targetRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: inference-gateway
  traffic:
    phase: PreRouting
    transformation:
      request:
        set:
          - name: X-Gateway-Base-Model-Name
            value: 'request.method == "GET" ? default(request.headers["x-model"], "") : string(json(request.body).model)'

HTTPRoute는 이 헤더와 경로가 모두 정확히 맞는 요청만 풀로 보냅니다. 등록한 경로는 /v1/chat/completions와 /v1/models 둘이고 경로 일치 방식은 Exact입니다. Qwen 파드의 8000 포트에는 추론 API와 함께 /sleep, /wake_up 같은 관리 엔드포인트가 열려 있습니다. 등록한 경로만 통과시키므로 이 엔드포인트로 가는 요청은 게이트웨이에서 404로 끝납니다. 클라이언트가 헤더를 직접 넣어도 본문의 값이 덮어쓰므로 헤더를 위조해 다른 풀을 고를 수도 없습니다.

게이트웨이 파드 2개는 서로 다른 가용 영역에 두었습니다. topologySpreadConstraints만으로는 분산이 걸리지 않았고 minDomains: 2와 matchLabelKeys: [pod-template-hash]를 함께 두자 두 파드가 다른 영역에 배치됐습니다. EPP는 풀마다 2개이고 리더 하나가 요청을 처리합니다.

게이트웨이로 들어오는 길은 둘입니다. BFF는 클러스터 안의 Service를 직접 호출하고 배치 작업은 게이트웨이 앞의 내부 Network Load Balancer(NLB)로 들어옵니다. 두 길 모두 같은 라우팅 규칙을 지납니다. 게이트웨이 구간에 걸린 시간은 1부의 구간별 측정값에 있습니다.

06

배치 부하에서 상담 요청을 지키는 두 층의 우선순위

Gemma 4 31B는 사용자가 기다리는 상담 요청과 나중에 처리해도 되는 번역, 요약 요청을 함께 받습니다. 배치 요청이 KV 캐시를 채우고 있으면 상담 요청은 그 뒤에서 기다립니다. 이 구성에서 우선순위를 지정하는 곳은 두 군데입니다.

  • 게이트웨이: InferenceObjective에 priority를 정의하고 요청은 x-llm-d-inference-objective 헤더로 그 이름을 고릅니다. llm-d의 flow control 문서에 따르면 기본 상태에서는 풀이 포화했을 때 priority가 0보다 낮은 요청을 HTTP 429로 거절합니다.
  • 엔진: vLLM을 --scheduling-policy=priority로 실행하고 요청 본문의 priority로 지정합니다. vLLM의 스케줄러 설정 문서에 따르면 값이 작을수록 먼저 처리합니다.

두 값은 방향이 반대입니다. 상담 요청은 게이트웨이에서 priority 10인 objective를, 엔진에서는 priority 0을 받습니다. 배치 요청은 각각 -1과 10입니다. 클라이언트는 이 값을 몰라도 됩니다. BFF가 업무 종류에 따라 헤더와 본문의 값을 함께 채웁니다.

yaml
# k8s/gemma/routes.yaml에서 발췌(주석 생략). Qwen에도 같은 두 개가 있습니다.
apiVersion: llm-d.ai/v1
kind: InferenceObjective
metadata:
  name: gemma-interactive
spec:
  priority: 10
  poolRefs:
    - name: gemma
---
apiVersion: llm-d.ai/v1
kind: InferenceObjective
metadata:
  name: gemma-batch
spec:
  priority: -1
  poolRefs:
    - name: gemma

어느 쪽이 효과가 있는지 4가지 경우로 나눠 측정했습니다. 배치 요청 32개를 끊임없이 보내 KV 캐시를 채운 상태에서 상담 요청을 1.5초마다 하나씩 60건 보냈습니다.

경우상담 TTFT p50p90배치 429 거절엔진의 대기 요청 수(평균)
우선순위 없음30,895ms39,154ms0건31.0
게이트웨이만11,183ms23,081ms1,907건15.3
엔진만190ms1,244ms0건17.9
둘 다193ms1,030ms1,988건9.3

표 10. 배치 부하 중 상담 요청의 TTFT와 배치 처리 결과(Gemma 4 31B, 2026년 11월 14일, 경우마다 90초씩 한 번). 요청은 모두 게이트웨이를 거쳤습니다

상담 요청과 배치 요청이 게이트웨이와 엔진에서 다뤄지는 방식을 나타낸 도식. 게이트웨이는 풀이 포화하면 priority가 -1인 배치 요청을 429로 거절하고 엔진은 priority 값이 작은 상담 요청을 대기열 맨 앞에 두며, 상담 요청의 TTFT 중앙값은 우선순위가 없으면 30.9초, 게이트웨이만 지정하면 11.2초, 엔진만 지정하거나 둘 다 지정하면 0.19초이다
그림 4. 우선순위가 작동하는 두 층. 대기열에 그린 요청의 수는 설명용이고 TTFT와 429 거절 건수, 엔진의 대기 요청 수는 표 10의 값입니다

상담 요청의 대기를 없앤 것은 엔진 우선순위입니다. TTFT 중앙값이 30.9초에서 0.19초가 됐습니다. 게이트웨이는 배치 요청을 거절해 엔진의 대기열을 줄였지만 이미 엔진에 들어간 배치 요청 뒤에서 기다리는 것은 그대로여서 11.2초였습니다. 배치의 출력 처리량은 4가지 경우 모두 초당 159토큰에서 176토큰이었습니다. 우선순위는 처리 순서를 바꾸고 전체 처리량은 바꾸지 않습니다.

한 모델이 대화형 요청과 배치 요청을 함께 받는다면 엔진 우선순위부터 켜는 것을 권고합니다. 적용할 때 볼 점이 두 가지 있습니다. 배치 클라이언트는 429를 받으므로 재시도 간격을 늘리는 처리가 필요합니다. 엔진 우선순위를 켜도 p90은 1.2초였습니다. 이 측정은 Gemma 4 31B로만 했습니다.

07

업무 시간 밖의 Qwen3.8-27B를 재우는 sleep

내부 업무용인 Qwen3.8-27B는 업무 시간 밖에는 요청이 거의 없습니다. 파드를 내리면 다시 띄우는 데 2분 넘게 걸리므로 내리지 않고 재웁니다. vLLM의 sleep mode는 파드를 그대로 둔 채 모델을 GPU에서 내리는 기능입니다. vLLM 문서에 따르면 level 1 sleep은 가중치를 호스트 메모리로 옮기고 KV 캐시를 비웁니다. 이 환경에서 GPU 메모리 사용량은 40,899MiB에서 2,299MiB로 줄었습니다.

다시 요청을 받는 방법걸린 시간남아 있는 것
sleep에서 복귀3.66초노드, 파드, 호스트 메모리의 가중치
웜 재시작(같은 노드에서 파드를 다시 띄움)123초노드, 이미지, 노드의 compile 캐시
콜드 스타트(새 노드)290초S3의 가중치와 compile 캐시

표 11. Qwen3.8-27B가 다시 요청을 받기까지의 시간(2026년 11월 14일). 복귀는 같은 파드에서 5회 반복한 값의 최대이고 나머지는 한 번 측정한 값입니다

구성은 표 12와 같습니다.

객체내용
CronJob qwen-sleep평일 19:00(Asia/Seoul)에 /sleep?level=1&mode=wait 호출
CronJob qwen-wake평일 08:30(Asia/Seoul)에 깨우기 API 호출
Deployment qwen-wake-apiPOST /wake만 제공. 잠들어 있으면 /wake_up 호출. 복제본 2개
Service vllm-qwen-admin관리 요청용 헤드리스 Service. NotReady 파드의 주소도 돌려줌
NetworkPolicy 2개Qwen의 8000 포트와 깨우기 API의 8080 포트에 정해진 파드만 허용

표 12. Qwen3.8-27B의 sleep 운영 구성

Qwen3.8-27B를 평일 19:00에 재우고 08:30에 깨우는 일정과, 잠든 동안 들어온 요청을 BFF가 깨우기 API로 먼저 깨운 뒤 게이트웨이로 보내는 흐름을 나타낸 도식. sleep 중 GPU 메모리 사용량은 40,899MiB에서 2,299MiB로 줄고 복귀는 3.66초이며 잠든 Qwen에 보낸 요청은 첫 내용까지 4.06초가 걸렸다
그림 5. Qwen3.8-27B의 sleep과 깨우기. 위는 평일 하루의 일정(Asia/Seoul)이고 아래는 잠든 동안 들어온 요청의 흐름과 잠든 파드를 일반 Service에서 빼는 방법입니다

구성할 때 놓치기 쉬운 설정이 3가지 있습니다.

  • 재울 때는 mode=wait를 줍니다. 진행 중인 요청이 끝난 뒤에 잠듭니다. 기본값 abort는 진행 중인 요청을 중단합니다.
  • readinessProbe는 /health가 아닌 /is_sleeping을 확인합니다. /health는 잠든 동안에도 200을 돌려주므로 그대로 두면 잠든 파드가 요청을 받습니다.
  • 관리 엔드포인트는 VLLM_SERVER_DEV_MODE=1로 열립니다. NetworkPolicy로 닿을 수 있는 파드를 제한했습니다.

잠든 동안 요청이 오면 BFF가 깨웁니다. BFF는 Qwen으로 갈 요청마다 깨우기 API를 먼저 호출합니다. 잠든 Qwen에 보낸 요청이 첫 내용을 받기까지의 시간은 1부에서 다룹니다.

sleep을 적용하기 전에 확인할 조건이 두 가지 있습니다. sleep은 노드를 그대로 두므로 노드 요금은 줄지 않고 줄어드는 것은 GPU 메모리 사용량입니다. 요금을 줄이려면 노드를 회수해야 하고 그때는 콜드 스타트를 받아들여야 합니다. 또 가중치가 호스트 메모리에 남으므로 노드의 시스템 메모리가 넉넉해야 합니다. sleep을 한 번 거친 뒤 컨테이너 메모리는 60.4GiB였고 g6e.4xlarge의 메모리는 128GiB입니다.

08

경계마다 좁힌 접근과 권한

구성 요소 사이의 경계마다 허용하는 출발지를 정했습니다. 인터넷에서 닿는 곳은 CloudFront뿐이고 안쪽으로 갈수록 허용 대상이 좁아집니다.

대상허용하는 출발지수단
CloudFrontIP당 5분 300회까지. /v1/* 요청은 BFF가 Amazon Cognito 액세스 토큰을 검증AWS WAF 속도 기반 규칙, 토큰 검증
내부 ALB(80)CloudFront VPC origin의 보안 그룹보안 그룹
BFF 파드(8080)내부 ALB에 연결된 백엔드 보안 그룹보안 그룹
게이트웨이 내부 NLB(80)배치 클라이언트의 보안 그룹보안 그룹
깨우기 API 파드(8080)BFF 파드, 깨우기 CronJob의 파드NetworkPolicy
Qwen 파드(8000)게이트웨이, EPP, 깨우기 API, 지표 수집기, ow-on-gpu/qwen-admin 라벨이 있는 관리용 파드NetworkPolicy

표 13. 경계별 접근 제한

AWS 권한은 모두 EKS Pod Identity로 주고 파드의 일마다 역할을 나눴습니다.

ServiceAccount허용하는 것
inference의 gemma, qwen, decider모델 버킷의 models/와 vllm-cache/ 읽기
model-jobs의 model-sync, cache-publish같은 경로에 쓰기
app의 bffbedrock-agentcore:InvokeWebSearch
monitoring의 지표 수집기Amazon Managed Service for Prometheus에 원격 쓰기

표 14. EKS Pod Identity로 연결한 역할. 앞의 이름은 네임스페이스입니다

요청 진입에서 AWS WAF의 속도 기반 규칙과 로그인 검증이 한 일과 그 측정 결과는 1부에서 다룹니다. NetworkPolicy가 적용되려면 Amazon VPC CNI 애드온에 넣어야 하는 설정은 3부에 있습니다.

남아 있는 틈도 적어 둡니다. 클러스터 안의 파드는 게이트웨이의 Service에 로그인 토큰 없이 추론 요청을 보낼 수 있습니다. Gemma 파드의 8000 포트에는 NetworkPolicy를 걸지 않았고 CloudFront와 내부 ALB 사이는 VPC 안에서 HTTP로 통신합니다. 클러스터를 여러 팀이 함께 사용한다면 이 3곳부터 좁히는 것을 권고합니다.

09

운영하면서 볼 지표와 고정 비용

지표는 Prometheus agent 하나가 수집해 Amazon Managed Service for Prometheus로 보냅니다. 수집 대상은 vLLM 파드 2개(5초 주기), EPP 파드 4개, 게이트웨이 파드 2개(15초 주기)입니다. 이 글의 최적화를 운영하면서 볼 지표는 다음 5가지입니다.

볼 것지표관련 챕터
첫 토큰까지의 시간vllm:time_to_first_token_seconds우선순위, 동시 실행
토큰 간격vllm:inter_token_latency_seconds동시 실행
실행 중, 대기 중 요청 수vllm:num_requests_running, vllm:num_requests_waiting동시 실행, 우선순위
KV 캐시 사용률vllm:kv_cache_usage_perc동시 실행
MTP 수락률vllm:spec_decode_num_accepted_tokens_total ÷ vllm:spec_decode_num_draft_tokens_totalMTP

표 15. 모델별로 나눠 보는 지표. 이름은 vLLM v0.33.0 파드의 /metrics에서 확인했습니다

모든 구성 요소가 실행 중일 때의 고정 비용은 시간당 약 11.35 USD로 추정됩니다. 2026년 11월 15일의 추정값은 약 10.05 USD였습니다. 그 뒤 Decider 노드를 g6.xlarge(시간당 0.9896 USD)에서 g6e.xlarge(시간당 2.2880 USD)로 바꿔 1.2984 USD가 늘었습니다. 그 가운데 앱 계층은 0.1857 USD입니다(내부 ALB 0.0225 USD, c7g.large 2대 0.1632 USD). 약 1.6%입니다. 사용량에 따라 부과되는 ALB 처리 단위, CloudFront 전송량, AWS WAF, Amazon Cognito 요금은 포함하지 않았습니다. GPU 노드는 실행 중인 동안 요금이 발생합니다. 서빙 파드를 0으로 줄이면 NodePool의 설정에 따라 Karpenter가 빈 GPU 노드를 회수합니다.

10

내 환경으로 옮길 때 그대로 둘 것과 다시 정할 것

그대로 가져갈 만한 것은 3가지이고 모델과 GPU가 달라도 적용됩니다.

  • 모델마다 NodePool을 두고 GPU 한도를 거는 구성
  • 가중치를 S3에 한 번 올리고 서빙 파드는 EKS Pod Identity 권한으로 S3에서만 읽는 공급 경로
  • 시작 시간을 4개 구간으로 나눠 측정하는 방법

모델이나 GPU가 다르면 다시 정할 것이 있습니다. 체크포인트의 양자화 형식은 GPU 세대가 지원하는 것으로 고릅니다. --gpu-memory-utilization은 기동 로그의 KV 캐시 크기를 보고 정합니다. compile 캐시는 구성이 바뀔 때마다 새 prefix로 게시합니다.

트래픽에 따라 정할 것도 있습니다. 동시에 겹치는 요청이 3건을 넘으면 MTP를 끄는 쪽을 검토합니다. 한 모델이 대화형 요청과 배치 요청을 함께 받으면 엔진 우선순위를 켭니다. 정해진 시간에만 사용하는 모델은 sleep으로 빠른 복귀를 얻을지, 노드를 회수해 요금을 줄이고 콜드 스타트를 받아들일지를 고릅니다.

1부는 이 구조 위에서 API 호출 한 건이 지나는 8개 단계를 따라가고 3부는 이 환경을 처음부터 구축하는 순서를 다룹니다.

The whole architecture in six layers

Serving an open-weight model yourself (a model whose weights are published, so you can download and run it) takes more than an inference engine on a GPU node. You also need an entry point for requests, routing that picks a model, a path that carries the weights to the GPU, and rules for creating and reclaiming nodes. OpenWeight on AWS GPU (OW on GPU) is a series that builds this setup from scratch on Amazon Elastic Kubernetes Service (Amazon EKS). The example environment serves Gemma 4 31B and Qwen3.8-27B together with vLLM, an open source inference engine, and the code is in the ow-on-gpu repository.

This post, Part 2, explains the architecture of that environment. It first splits the whole setup into six layers and shows what each component does. It then walks through four optimizations on the Amazon EKS side, with the measured values.

Part 1 follows one API call through this architecture in eight stages, and Part 3 builds the same environment in ten steps. The values in this post were measured on November 14 and 15, 2026, in the Seoul Region (ap-northeast-2), and each table says how many times. I wrote it for readers who know the basics of Kubernetes and AWS (pods, Deployments, IAM roles) and are setting up LLM serving for the first time.

Figure 1 shows the whole architecture on one page. Each section of this post zooms in on one part of it.

An architecture diagram with two paths on one page: the request path from the browser through CloudFront, the internal ALB, the BFF and the gateway to Gemma 4 31B and Qwen3.8-27B on the GPU nodes, and the supply path where a sync Job uploads Hugging Face checkpoints to the S3 model bucket and the GPU nodes get weights, the compile cache and the container image from that bucket and the image registry. The lower part lists the six steps from model sync to the inference request, the order in which the BFF picks a model, the measured segments, and the access limits at each boundary
Figure 1. The whole architecture at a glance. Solid lines are requests and data, dashed lines are sign-in, permissions and metrics. Badges 0 to 4 are the order in which models and images reach the GPU nodes, and 5 is the inference request

What each layer does

The environment is a single Amazon EKS 1.37 cluster in the Seoul Region. There are many components, but grouped by what they do they form six layers. Each layer has its own settings to change and its own metrics to watch, so learning this split first makes the later sections easier to read.

LayerComponentsWhat it does
AppAmazon CloudFront, AWS WAF, Amazon Cognito, internal ALB, 2 BFF podsServes the static page, limits request rate, verifies the sign-in token, picks the model and the priority, runs tools
Gateway2 agentgateway pods, one EPP per modelPicks the per-model pool from the model value in the request body, limits the exposed paths, rejects batch requests when a pool is saturated
Serving2 vLLM pods (Gemma 4 31B, Qwen3.8-27B), Strands Decider 12BInference, the order in which requests run, the model judgment
Model and image supplyAmazon S3 model bucket, sync Job, cache-publish JobCarries weights and the compile cache to the GPU nodes
Node management6 Karpenter NodePools, 1 managed node groupCreates and reclaims nodes per workload
ObservabilityPrometheus agent, Amazon Managed Service for PrometheusCollects and stores metrics from vLLM, the EPPs and the gateway

Table 1. Components by layer and what they do

The left side of Figure 1 is the request path. A request goes through Amazon CloudFront, the internal Application Load Balancer (ALB), the BFF and the gateway, in that order, and reaches vLLM. The BFF (Backend for Frontend) is the service between the page and the models that checks the sign-in and decides which model gets the request. CloudFront is the only part open to the internet, and everything else is inside the VPC.

The right side of the figure is the supply path. It is how the model weights and the container image get onto a GPU node, and it runs in the order of badges 0 to 4. The request path sets the response speed, and the supply path sets how long a new pod takes before it can accept requests.

Besides the inference models, the diagram has two components that help with a request. Strands Decider 12B runs on one g6e.xlarge node and is called through the /decide path of the gateway. It does not use an InferencePool, and the HTTPRoute sends the request straight to its Service. This environment moved the Decider from the v1 2B model (g6.xlarge) to the 12B model of Strands Decider v2 on November 24, 2026. The request and response formats are the same as in v1, so the BFF was not changed. Amazon Bedrock AgentCore Web Search is a tool the BFF runs, so the gateway and vLLM setup did not change. Part 1 covers what the two components do for each request and the measured values, and Part 3 covers how to prepare the serving image of Decider 12B.

Task assignment and the data policy

The models are split by task and by data. Gemma 4 31B takes customer requests and Qwen3.8-27B takes internal work.

TaskModelPriority
Support chatbot (looks up orders with function calling)Gemma 4 31Binteractive
Product description translation, review summariesGemma 4 31Bbatch
Attribute extraction from product images, document OCRQwen3.8-27Binteractive or batch
In-house coding agentQwen3.8-27Binteractive

Table 2. Tasks and their models. interactive is a request a user is waiting on, batch is a request that can be handled later

The data policy is one line. Requests that contain personal data go only to Gemma 4 31B. Data with a fixed format, such as resident registration numbers and card numbers, is caught first by a rule in the BFF, and Strands Decider 12B helps with the cases that have no format.

01

Separate nodes for each workload

One managed node group and six NodePools

This section explains which workload runs on which node. GPU nodes are expensive and come in few types, so what goes on a GPU node and what does not has to be separated at the node level. The node that runs Karpenter itself is needed before Karpenter starts, so it comes from a managed node group.

Node setInstancesWorkloadsIsolation and limit
Managed node group addons2 x m7g.largeKarpenter, CoreDNS, AWS Load Balancer ControllerCriticalAddonsOnly taint
NodePool system2 x c7i-flex.xlargeGateway, EPPs, wake API, Prometheus agent, sync JobLimit of 32 CPUs
NodePool app2 x c7g.large2 BFF podsow-on-gpu/app taint, limit of 8 CPUs
NodePool gemma-od1 x g6e.4xlargeGemma 4 31Bnvidia.com/gpu taint, limit of 1 GPU
NodePool qwen-od1 x g6e.4xlargeQwen3.8-27Bnvidia.com/gpu taint, limit of 1 GPU
NodePool decider1 x g6e.xlargeStrands Decider 12Bnvidia.com/gpu taint, limit of 1 GPU
NodePool benchCreated only during measurementsLoad generator Jobsow-on-gpu/bench taint, limit of 16 CPUs

Table 3. Node sets and workloads (instances as of November 24, 2026). Every node Karpenter creates is On-Demand, and workloads run in the private subnets of the VPC

The gateway and the EPPs are the point both models pass through, so the two system nodes are in different Availability Zones and the replicas are spread across them. The BFF uses Graviton nodes, and the load generator uses nodes that exist only during measurements. The split keeps measurement load from competing for CPU with the pods on the serving path.

A GPU NodePool that holds one node per model

There is one GPU NodePool per model. The one below is for Gemma, and the one for Qwen differs only in its name.

yaml
# excerpt from k8s/base/nodepools.yaml
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
  name: gemma-od
spec:
  template:
    spec:
      nodeClassRef:
        group: karpenter.k8s.aws
        kind: EC2NodeClass
        name: vllm
      requirements:
        - key: node.kubernetes.io/instance-type
          operator: In
          values: ["g6e.4xlarge"]
        - key: karpenter.sh/capacity-type
          operator: In
          values: ["on-demand"]
      taints:
        - key: nvidia.com/gpu
          value: "true"
          effect: NoSchedule
  limits:
    nvidia.com/gpu: 1
  disruption:
    consolidationPolicy: WhenEmpty
    consolidateAfter: 30m

Three settings in this manifest matter.

  • nvidia.com/gpu: 1 under limits caps this NodePool at one GPU. According to the Karpenter documentation, a NodePool over its limit creates no new nodes. Raising the replica count by mistake does not add GPU nodes.
  • taints keeps pods that do not tolerate this taint off the GPU nodes. The vLLM pod picks its own NodePool with a toleration for the same key and a karpenter.sh/nodepool nodeSelector.
  • consolidationPolicy: WhenEmpty reclaims only nodes with no workload pods, after 30 minutes. The node has to stay while a pod is recreated, which is what makes the warm restart described later possible.

There is no Availability Zone requirement, so Karpenter picks a zone that has capacity. When I checked, g6e.4xlarge was offered in only two of the four Availability Zones of the Seoul Region, ap-northeast-2a and ap-northeast-2b.

g6e.4xlarge and FP8 checkpoints

A g6e.4xlarge has one NVIDIA L40S. It comes with 16 vCPUs, 128 GiB of memory and 600 GB of instance store, and the product page lists 48 GB of GPU memory. The value in the vLLM startup log was 44.39 GiB.

The GPU generation decides the checkpoint format. FP8 is a quantization format that stores weights as 8-bit floating point. The L40S is an Ada generation GPU (compute capability 8.9), and the quantization support table in the vLLM documentation lists llm-compressor FP8 as supported on Ada and Hopper. So both models use FP8-dynamic checkpoints.

ModelCheckpointWeight filesSize on the GPU
Gemma 4 31BRedHatAI/gemma-4-31B-it-FP8-dynamic33.27 GB30.63 GiB
Qwen3.8-27BAzatAI/Qwen3.8-27B-FP8-dynamic36.78 GB34.39 GiB

Table 4. Checkpoints of the two models. File sizes use 1 GB = 10^9 bytes, and the size on the GPU is the Model loading took value in the vLLM log

Qwen3.8-27B also has an official block FP8 checkpoint whose weights are 5.9 GB smaller. In the vLLM v0.33.0 source, however, the CUTLASS kernel for block FP8 is supported only on compute capability 9.0 and later. So I chose the per-channel checkpoint, which the documentation lists as supported on Ada, and did not check how block FP8 behaves on the L40S. If you use a different GPU, I recommend checking which quantization formats that generation supports before choosing a checkpoint.

02

How models and images reach the GPU nodes

Weights uploaded to S3 once and read only from S3

This section explains where more than 30 GiB of weights live and with which permission they reach a GPU node. There is one principle. Serving pods never download from Hugging Face and read only from an Amazon Simple Storage Service (Amazon S3) bucket. This keeps the speed and availability of an external repository from affecting the start of a serving pod.

A sync Job uploads three repositories (Gemma 4 31B, Qwen3.8-27B and Decider 12B), pinned by revision hash, to the bucket. It pipes each file to S3 with s5cmd pipe as it downloads, so nothing is staged on local disk, and it compares the hash computed during the download with the value Hugging Face reports. The three repositories add up to 45 objects, 94.07 GB. The first sync, on November 14, 2026, included the Decider v1 in use then and its base model: 73 objects, 74.90 GB (69.8 GiB), with 491.4 s to transfer and verify. Adding Decider 12B (13 objects, 23.97 GB) on November 24, 2026 took 314.9 s. The bucket is laid out as follows.

text
s3://<bucket>/models/gemma-4-31B-it-FP8-dynamic/
s3://<bucket>/models/Qwen3.8-27B-FP8-dynamic/
s3://<bucket>/models/strands-decider-12B-gemma4-v2-2611/
s3://<bucket>/vllm-cache/v0.33.0-gemma4-31b-fp8-l40s/
s3://<bucket>/vllm-cache/v0.33.0-qwen38-27b-fp8-l40s/

models/ holds the weights and vllm-cache/ holds the compile cache described later. The Decider 12B checkpoint holds the full weights with the adapter merged in, so no separate base model is uploaded.

Permissions come from EKS Pod Identity. There are two AWS Identity and Access Management (IAM) roles, one for reading and one for writing. The read role is attached to the three ServiceAccounts of the serving pods (gemma, qwen, decider), and the write role only to the sync Job and the cache-publish Job. Serving pods cannot upload anything to the bucket, and no manifest contains credentials. Traffic to the bucket goes through the S3 gateway endpoint of the VPC.

Disk and image on a GPU node

The vLLM image (vllm/vllm-openai:v0.33.0) is 9.74 GB. The EC2NodeClass of the GPU nodes decides where that image is stored and when the download starts.

yaml
# excerpt from k8s/base/ec2nodeclasses.yaml (comments and some fields left out)
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
metadata:
  name: vllm
spec:
  amiSelectorTerms:
    - alias: al2023@v20261107
  instanceStorePolicy: RAID0
  userData: |
    #!/bin/bash
    systemd-run --unit=prepull-vllm --no-block /bin/bash -c '
      until ctr --namespace k8s.io version >/dev/null 2>&1; do sleep 1; done
      ctr --namespace k8s.io images pull docker.io/vllm/vllm-openai:v0.33.0
    '

The alias in amiSelectorTerms pins a release of the EKS optimized AL2023 AMI, and GPU nodes get the variant with NVIDIA drivers. instanceStorePolicy: RAID0 makes the instance store the storage for kubelet and containerd. On the GPU nodes 559 GB was mounted, and the image was stored there. The script in userData starts pulling the image while the node is still booting. The next section shows the effect of this pre-pull.

The vLLM pod that receives weights and the compile cache

These are the parts of the Gemma Deployment that concern the supply path.

yaml
# excerpt from k8s/gemma/deployment.yaml
      initContainers:
        - name: cache-restore
          image: vllm/vllm-openai:v0.33.0
          command: ["python3", "/scripts/cache-restore.py"]
          env:
            - name: CACHE_PREFIX
              value: vllm-cache/v0.33.0-gemma4-31b-fp8-l40s
      containers:
        - name: vllm
          image: vllm/vllm-openai:v0.33.0
          args:
            - s3://$(MODEL_BUCKET)/models/gemma-4-31B-it-FP8-dynamic
            - --load-format=runai_streamer
            - --gpu-memory-utilization=0.90
          env:
            - name: VLLM_CACHE_ROOT
              value: /vllm-cache
            - name: HF_HUB_OFFLINE
              value: "1"
      volumes:
        - name: vllm-cache
          hostPath:
            path: /var/cache/vllm

The model argument is an s3:// path and the loader is runai_streamer. According to the vLLM documentation, Run:ai Model Streamer is a library that reads tensors concurrently and streams them into GPU memory. There is no step that first downloads the weights to the node disk. HF_HUB_OFFLINE=1 keeps a misconfigured pod from quietly fetching from Hugging Face. The initContainer cache-restore downloads the compile cache from S3 to a hostPath on the node.

03

Three actions that cut the cold start from 394 s to 260 s

Results measured in four phases

A new serving pod on a GPU node takes minutes before it accepts requests. When nodes are scaled in and out, or when you recover from a failure, that time is a gap in service. I call a start on a new node a cold start, and recreating only the pod on the same node a warm restart.

The time from pod creation to Ready is split into four phases and the rest (other). Each phase waits for something different, so each is shortened in a different way. The baseline is the configuration before any optimization, and the optimized configuration is what serves today.

PhaseMeasured byBaselineOptimizedBaselineOptimized
Node provisioningNodeClaim creation to the node turning ReadyKarpenter creates a g6e.4xlargeSame55.071.0
Image pullThe kubelet Pulled eventStarts after the pod is scheduledStarts while the node boots111.171.0
Weight loadModel loading took in the vLLM logThe default loader reads a path mounted with Mountpoint for Amazon S3runai_streamer streams the s3:// path59.619.2
Engine initinit engine ... took in the vLLM logThe compile cache is created in the container and lost with the podThe compile cache in S3 is restored to a hostPath95.523.7
OtherTotal minus the four phases above72.775.1
TotalPod creation to Ready394260

Table 5. Cold start of Gemma 4 31B by phase (seconds, November 14, 2026, one run per configuration). Apart from the loader, the engine flags, the model and the vLLM version are the same in both

ScenarioGemma 4 31BQwen3.8-27B
Cold start, baseline394 sNot measured
Cold start, optimized260 s290 s
Warm restart, baseline214 sNot measured
Warm restart, optimized86 s123 s

Table 6. Time from pod creation to Ready by scenario (November 14, 2026, one run per scenario)

The cold start of Gemma 4 31B dropped by 134 s (34%) and the warm restart by 128 s (60%). Figure 2 shows the phases of each scenario together with the action applied to each phase.

An infographic that puts the cold start breakdown and the optimizations on one page. For Gemma 4 31B the time from pod creation to Ready went from 394 s to 260 s for a cold start and from 214 s to 86 s for a warm restart. Image pull went from 111.1 s to 71.0 s with a pre-pull during node boot, weight load from 59.6 s to 19.2 s with runai_streamer, and engine init from 95.5 s to 23.7 s with a restored compile cache, shown as bars per scenario and a table of actions
Figure 2. The four cold start phases and the action for each. Qwen3.8-27B was measured only in the optimized configuration

A different action for each phase

The image pre-pull does not shorten the download. It moves the start of the download earlier. In the optimized configuration, the user data of the node starts the pull as soon as containerd is up, and kubelet picks up the download in progress. It is worth applying where new nodes come up often.

The streaming loader made the weight load 3.1x faster. In a warm restart it was 59.1 s and 19.6 s, so this phase did not depend on whether the node was new. If your weights are in S3, apply it with --load-format=runai_streamer, an s3:// path and a Pod Identity permission. I also set RUNAI_STREAMER_NO_BOTO3_SESSION=0 so that Run:ai Model Streamer uses the credentials from boto3.

The compile cache cut engine init from 95.5 s to 23.7 s. vLLM finishes torch.compile before it accepts requests, so compile time goes straight into start-up time. Most of the difference is that compile (61.0 s to 0.9 s). The cache is kept in two places. On the hostPath of the node it survives when the pod restarts on the same node, and published to S3 it is restored by the initContainer on a new node. The cache of Gemma 4 31B was 522 objects, 90.8 MB, and the restore took 3.3 s.

There is one rule for running the cache. Put the vLLM version, the model, the precision and the GPU in the S3 prefix name, and publish to a new prefix whenever one of them changes. On November 15, 2026, I started Qwen with one flag changed, the existing cache did not match, and the compile took 62.6 s.

What remains after the optimizations is node provisioning and other, 146.1 s of the 260 s. Node provisioning alone ranged from 55 s to 118 s on the same day. Rather than using the values in this post as estimates, I recommend measuring with the same evidence (the timestamps of the NodeClaim and the pod, the kubelet Pulled event, and two lines of the vLLM log).

04

The number of concurrent requests set by GPU memory

The KV cache: what is left after the weights

Once a pod is Ready, capacity comes down to how many requests one GPU runs at the same time. The KV cache sets that number. The KV cache (key-value cache) is the space in GPU memory that keeps the results computed for tokens already processed, so they are not computed again for the next token. Every running request takes a share of it, so when the KV cache is full the next request waits.

vLLM uses the fraction of GPU memory given by --gpu-memory-utilization, and whatever is left after the weights and the memory needed to run is reserved as the KV cache.

text
KV cache memory = GPU memory × gpu-memory-utilization - weights and non-torch memory - peak activations

Gemma: 44.39 × 0.90 - 31.13 - 3.45 = 5.37 GiB
Qwen:  44.39 × 0.90 - 34.74 - 2.76 = 2.45 GiB

With a checkpoint of 30-odd GiB on a 48 GB GPU, a single-digit number of GiB is left for the KV cache. At the first value I tried, 0.85, Qwen3.8-27B had only 0.24 GiB left for the KV cache and the engine could not start. It started only at 0.90. Where the weights take most of the GPU memory, this value even decides whether the engine starts.

Gemma 4 31B: as many requests as fit in the KV cache

The SLO (service level objective) of this environment has two parts. TTFT (time to first token) is the time from sending a request to receiving the first token, and its p99 must be 500 ms or less. ITL (inter-token latency) is the gap between the chunks of a streamed response, and its p99 must be 50 ms or less. The load went straight to the vLLM Service without the gateway, and concurrency was raised in 7 levels from 1 to 64.

WorkloadInput, output tokensConcurrency limitPeak output throughputHighest concurrency with TTFT p99 within 500 ms
S1 Short chat256, 12845447.0 tok/s8
S2 Summarize and generate1,024, 25612164.7 tok/s1
S3 Classification512, 1624114.7 tok/s4
S4 Long-context RAG4,096, 256781.8 tok/sNone

Table 7. Results of Gemma 4 31B by workload (November 14, 2026, random-token prompts, one run per level). The concurrency limit is the number of requests the engine actually ran at concurrency 64

A GPU computes many requests together in one batch, so total throughput grows as requests are added (Gemma 4 31B: 18.5 tok/s at concurrency 1, 424.4 tok/s at 32). The longer a request, the more KV cache it takes, and the fewer requests run at once. Past the limit, raising concurrency adds no throughput and only lengthens TTFT. For S2, throughput was 163.6, 164.7 and 164.0 tok/s at concurrency 16, 32 and 64, while TTFT p99 grew to 19 s, 38 s and 91 s.

ITL was over the target regardless of load. Even at concurrency 1, with one request at a time, ITL p99 was between 57.6 ms and 58.6 ms and the median was 54.0 ms. The 54 ms per token is the speed of this checkpoint on the L40S. Lowering the load improves TTFT. Meeting the ITL target takes a different GPU or checkpoint, or a new target.

The limit of three on Qwen3.8-27B and MTP

Qwen3.8-27B ran only 3 requests at the same time, however much load was added. The cause is MTP (Multi-Token Prediction). MTP speeds up a single request by guessing several next tokens with a prediction head of the model and having the main model verify them in one pass. By the block arithmetic in the vLLM v0.33.0 source, the 3 speculative tokens make each request hold four times the state blocks. One request holds 13 blocks, and the KV cache is 46 blocks, so the engine stops at 3.

ItemMTP on (3 speculative tokens)MTP off
KV cache blocks per request134
KV cache2.45 GiB, 46 blocks4.0 GiB, 82 blocks
Concurrency limit320
Speed of one request (concurrency 1)32.5 tok/s19.2 tok/s
Peak output throughput91.2 tok/s281.8 tok/s
Highest concurrency with TTFT p99 within 500 ms28

Table 8. Qwen3.8-27B on S1 with MTP on (November 14, 2026) and off (November 15, 2026). Random-token prompts, one run each

MTP makes a single request 1.7 times faster and in return ties concurrency to 3. So the criterion is how many requests overlap. If a task never has more than 3 requests at once, MTP on is better. If 4 or more overlap, as with an in-house coding agent, MTP off is better. These are single runs with random-token prompts, so on a real workload the speed difference changes with how often the guesses are right.

An infographic in four panels on the GPU memory split of the L40S and the concurrency results. The SLO is TTFT p99 of 500 ms or less and ITL p99 of 50 ms or less. After the weights and activations, 5.37 GiB is left for the KV cache of Gemma 4 31B and 2.45 GiB for Qwen3.8-27B. On S1, Gemma runs 45 requests at concurrency 64 and reaches 447.0 tok/s, while Qwen with MTP on is held at 3 requests and stays between 85.0 and 91.2 tok/s. With MTP off the limit becomes 20 and the speed of one request drops from 32.5 to 19.2 tok/s
Figure 3. GPU memory split and concurrent requests. The bars in panel 3 are the output throughput of S1 short chat, and the pink bars are the levels that reached the concurrency limit

When you look at capacity, I recommend not relying on the KV cache size in the startup log alone. Watch the number of running requests (vllm:num_requests_running) and the KV cache usage (vllm:kv_cache_usage_perc) in the engine metrics as well. The limit on Qwen could not be read from the token count in the log and showed up in these two metrics.

05

A gateway that picks the pool from the model value in the body

InferencePool, EPP, agentgateway

The gateway layer hands a request to the vLLM pod of the right model. With two models you could expose two endpoints, but this environment has one endpoint and lets the gateway tell the models apart per request. Clients and the BFF need to know one address, and adding a model means adding a route rule.

Gateway API Inference Extension (GAIE) is a project that adds resources for inference workloads to the Kubernetes Gateway API. An InferencePool is a group of pods that serve the same model, and it is the backend of an HTTPRoute. The EPP (Endpoint Picker) is the component that picks the pod in a pool to receive a request. agentgateway is the gateway implementation that reads these resources and forwards the traffic.

ComponentVersionWhat it does here
Gateway API CRDsv1.6.3Gateway, HTTPRoute
GAIE CRDsv1.6.2InferencePool
llm-d-routerv1.0.02 EPPs per pool, InferenceObjective
agentgatewayv1.7.02 gateway pods, body-based routing
AWS Load Balancer Controllerv3.6.3Internal NLB in front of the gateway, internal ALB in front of the BFF

Table 9. Components of the gateway layer and their versions (as of November 14, 2026)

According to the GAIE v1.6.0 release notes, the EPP and InferenceObjective moved to the llm-d project in that version. So only the InferencePool CRD comes from GAIE, and the EPP and InferenceObjective come from llm-d-router. Each pool here has one vLLM pod, so the EPP has a single candidate, and its scheduling time was 0.03 ms per request. What the EPP really does here is judge whether a pool is saturated and reject low-priority requests.

The model value moved to a header, and paths matched exactly

In an OpenAI-compatible API the model name is in the request body, not in the URL. An HTTPRoute picks a backend by path and headers, which is not enough to tell two models apart, so the model value in the body is copied into a header before routing. According to the agentgateway documentation, a single AgentgatewayPolicy does this.

yaml
# excerpt from k8s/gateway/gateway.yaml (comments left out)
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayPolicy
metadata:
  name: model-routing
spec:
  targetRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: inference-gateway
  traffic:
    phase: PreRouting
    transformation:
      request:
        set:
          - name: X-Gateway-Base-Model-Name
            value: 'request.method == "GET" ? default(request.headers["x-model"], "") : string(json(request.body).model)'

An HTTPRoute sends a request to a pool only when this header and the path both match exactly. Two paths are registered, /v1/chat/completions and /v1/models, and the path match type is Exact. Port 8000 of the Qwen pod serves the inference API together with management endpoints such as /sleep and /wake_up. Because only the registered paths get through, a request to those endpoints ends with a 404 at the gateway. A header set by the client is overwritten by the value from the body, so forging the header does not select another pool either.

The 2 gateway pods are in different Availability Zones. topologySpreadConstraints alone did not spread them, and they landed in different zones once minDomains: 2 and matchLabelKeys: [pod-template-hash] were set together. Each pool has 2 EPPs, and the leader handles the requests.

There are two ways into the gateway. The BFF calls the Service inside the cluster, and batch jobs come in through an internal Network Load Balancer (NLB) in front of the gateway. Both go through the same routing rules. The time spent in the gateway segment is in the per-segment measurements of Part 1.

06

Two layers of priority that protect interactive requests under batch load

Gemma 4 31B takes support requests a user is waiting on together with translation and summary requests that can wait. When batch requests fill the KV cache, a support request waits behind them. In this setup priority is set in two places.

  • Gateway: an InferenceObjective defines a priority, and a request selects it by name with the x-llm-d-inference-objective header. According to the llm-d flow control documentation, in the default state a request with a priority below 0 is rejected with HTTP 429 when the pool is saturated.
  • Engine: vLLM runs with --scheduling-policy=priority, and the request body carries priority. According to the vLLM scheduler configuration documentation, a smaller value runs first.

The two values point in opposite directions. A support request gets the objective with priority 10 at the gateway and priority 0 in the engine. A batch request gets -1 and 10. Clients do not need to know these values. The BFF fills in the header and the body value from the task type.

yaml
# excerpt from k8s/gemma/routes.yaml (comments left out). Qwen has the same two.
apiVersion: llm-d.ai/v1
kind: InferenceObjective
metadata:
  name: gemma-interactive
spec:
  priority: 10
  poolRefs:
    - name: gemma
---
apiVersion: llm-d.ai/v1
kind: InferenceObjective
metadata:
  name: gemma-batch
spec:
  priority: -1
  poolRefs:
    - name: gemma

To see which layer has the effect, I measured four cases. With 32 batch requests sent continuously to fill the KV cache, 60 support requests were sent, one every 1.5 s.

CaseSupport TTFT p50p90Batch 429 rejectionsRequests waiting in the engine (mean)
No priority30,895 ms39,154 ms031.0
Gateway only11,183 ms23,081 ms1,90715.3
Engine only190 ms1,244 ms017.9
Both193 ms1,030 ms1,9889.3

Table 10. TTFT of support requests under batch load, and what happened to the batch (Gemma 4 31B, November 14, 2026, one 90 s run per case). Every request went through the gateway

A diagram of how support requests and batch requests are handled at the gateway and in the engine. When the pool is saturated the gateway rejects batch requests of priority -1 with 429, and the engine puts support requests, which have the smaller priority value, at the head of the queue. The median TTFT of support requests is 30.9 s with no priority, 11.2 s with the gateway only, and 0.19 s with the engine only or with both
Figure 4. The two layers where priority works. The number of requests drawn in the queue is illustrative, and TTFT, the 429 counts and the engine queue are the values of Table 10

Engine priority is what removed the wait of support requests. The median TTFT went from 30.9 s to 0.19 s. The gateway shortened the engine queue by rejecting batch requests, but a support request still waited behind the batch requests already in the engine, so it was 11.2 s. Batch output throughput was between 159 and 176 tokens per second in all four cases. Priority changes the order, not the total throughput.

If one model takes interactive and batch requests together, I recommend turning on engine priority first. Two things to watch when you apply it. Batch clients receive 429, so they need a longer retry interval. Even with engine priority on, p90 was 1.2 s. This measurement was done with Gemma 4 31B only.

07

Sleep for Qwen3.8-27B outside business hours

Qwen3.8-27B, used for internal work, gets almost no requests outside business hours. Taking the pod down means more than 2 minutes to bring it back, so it is put to sleep instead. Sleep mode in vLLM takes the model off the GPU while the pod stays. According to the vLLM documentation, level 1 sleep moves the weights to host memory and clears the KV cache. In this environment GPU memory use went from 40,899 MiB to 2,299 MiB.

How it gets back to servingTimeWhat is kept
Wake from sleep3.66 sThe node, the pod, the weights in host memory
Warm restart (the pod recreated on the same node)123 sThe node, the image, the compile cache on the node
Cold start (a new node)290 sThe weights and the compile cache in S3

Table 11. Time until Qwen3.8-27B accepts requests again (November 14, 2026). The wake time is the maximum of 5 runs on one pod, and the others are single runs

The setup is in Table 12.

ObjectWhat it does
CronJob qwen-sleepCalls /sleep?level=1&mode=wait at 19:00 on weekdays (Asia/Seoul)
CronJob qwen-wakeCalls the wake API at 08:30 on weekdays (Asia/Seoul)
Deployment qwen-wake-apiServes only POST /wake. Calls /wake_up if the model is asleep. 2 replicas
Service vllm-qwen-adminHeadless Service for management requests. Also returns the addresses of NotReady pods
2 NetworkPoliciesAllow only listed pods to reach port 8000 of Qwen and port 8080 of the wake API

Table 12. The objects that run sleep for Qwen3.8-27B

A diagram of the schedule that puts Qwen3.8-27B to sleep at 19:00 and wakes it at 08:30 on weekdays, and of the flow where the BFF wakes the model through the wake API before sending a request that arrived during sleep to the gateway. GPU memory use during sleep drops from 40,899 MiB to 2,299 MiB, the wake takes 3.66 s, and a request sent to a sleeping Qwen took 4.06 s to its first content
Figure 5. Sleep and wake for Qwen3.8-27B. The top is the schedule of a weekday (Asia/Seoul), and the bottom is the flow of a request that arrives during sleep and how a sleeping pod is taken out of the regular Service

Three settings are easy to miss.

  • Pass mode=wait when putting the model to sleep. It goes to sleep after in-flight requests finish. The default, abort, cancels them.
  • The readinessProbe checks /is_sleeping, not /health. /health returns 200 during sleep too, so with it a sleeping pod would keep receiving requests.
  • The management endpoints are opened by VLLM_SERVER_DEV_MODE=1. A NetworkPolicy limits which pods can reach them.

When a request arrives during sleep, the BFF wakes the model. The BFF calls the wake API before every request bound for Qwen. Part 1 covers how long a request sent to a sleeping Qwen takes to reach its first content.

Check two conditions before you apply sleep. Sleep keeps the node, so the node charge does not go down, and what goes down is GPU memory use. Lowering the charge means reclaiming the node, and then you accept the cold start. The weights also stay in host memory, so the node needs enough system memory. After one sleep the container memory was 60.4 GiB, and a g6e.4xlarge has 128 GiB.

08

Access and permissions narrowed at each boundary

Each boundary between components has its own allowed sources. Only CloudFront can be reached from the internet, and the allowed sources get narrower toward the inside.

TargetAllowed sourceMeans
CloudFrontUp to 300 requests per 5 minutes per IP. For /v1/* the BFF verifies the Amazon Cognito access tokenAWS WAF rate-based rule, token verification
Internal ALB (80)The security group of the CloudFront VPC originSecurity group
BFF pods (8080)The backend security group attached to the internal ALBSecurity group
Internal NLB of the gateway (80)The security group of the batch clientSecurity group
Wake API pods (8080)BFF pods, the pods of the wake CronJobNetworkPolicy
Qwen pod (8000)Gateway, EPP, wake API, metrics collector, management pods with the ow-on-gpu/qwen-admin labelNetworkPolicy

Table 13. Access limits at each boundary

Every AWS permission comes from EKS Pod Identity, with a separate role for each job a pod does.

ServiceAccountWhat it may do
gemma, qwen, decider in inferenceRead models/ and vllm-cache/ in the model bucket
model-sync, cache-publish in model-jobsWrite to the same paths
bff in appbedrock-agentcore:InvokeWebSearch
The metrics collector in monitoringRemote write to Amazon Managed Service for Prometheus

Table 14. Roles attached through EKS Pod Identity. The name after "in" is the namespace

Part 1 covers what the AWS WAF rate-based rule and the sign-in check did at request entry, with the measured results. The setting the Amazon VPC CNI add-on needs before a NetworkPolicy is enforced is in Part 3.

Some gaps remain. A pod inside the cluster can send an inference request to the Service of the gateway without a sign-in token. Port 8000 of the Gemma pod has no NetworkPolicy, and CloudFront and the internal ALB talk over HTTP inside the VPC. If several teams share the cluster, I recommend closing these three first.

09

Metrics to watch in operation, and the fixed cost

One Prometheus agent collects the metrics and sends them to Amazon Managed Service for Prometheus. The targets are 2 vLLM pods (every 5 s), 4 EPP pods and 2 gateway pods (every 15 s). These are the five things to watch while operating the optimizations in this post.

What to watchMetricRelated section
Time to first tokenvllm:time_to_first_token_secondsPriority, concurrent requests
Gap between tokensvllm:inter_token_latency_secondsConcurrent requests
Running and waiting requestsvllm:num_requests_running, vllm:num_requests_waitingConcurrent requests, priority
KV cache usagevllm:kv_cache_usage_percConcurrent requests
MTP acceptance ratevllm:spec_decode_num_accepted_tokens_total ÷ vllm:spec_decode_num_draft_tokens_totalMTP

Table 15. Metrics to break down by model. The names were checked on /metrics of the vLLM v0.33.0 pods

With every component running, the fixed cost is estimated at about 11.35 USD per hour. The estimate on November 15, 2026 was about 10.05 USD. Since then the Decider node changed from g6.xlarge (0.9896 USD per hour) to g6e.xlarge (2.2880 USD per hour), which added 1.2984 USD. Of that, the app layer is 0.1857 USD (0.0225 USD for the internal ALB, 0.1632 USD for two c7g.large), about 1.6%. ALB capacity units, CloudFront data transfer, AWS WAF and Amazon Cognito charges, which depend on usage, are not included. GPU nodes are charged while they run. When the serving pods are scaled to 0, Karpenter reclaims the empty GPU nodes, as set in the NodePools.

10

What to keep and what to decide again in your own environment

Three things are worth taking as they are, and they apply even with different models and GPUs.

  • One NodePool per model, with a GPU limit
  • A supply path where weights go to S3 once and serving pods read only from S3 with an EKS Pod Identity permission
  • Measuring start-up time in four phases

A different model or GPU means deciding some things again. Choose a checkpoint quantization format that the GPU generation supports. Set --gpu-memory-utilization by the KV cache size in the startup log. Publish the compile cache to a new prefix every time the configuration changes.

Some things depend on traffic. If more than 3 requests overlap, consider turning MTP off. If one model takes interactive and batch requests together, turn on engine priority. For a model used only at set hours, choose between sleep, with its fast wake, and reclaiming the node, which lowers the charge and brings the cold start.

Part 1 follows the eight stages of one API call on top of this architecture, and Part 3 covers the order in which to build this environment from scratch.

참고 자료References

No.출처Source종류Kind확인한 날Checked
1Learn how EKS Pod Identity grants pods access to AWS servicesAmazon EKS 사용 설명서Amazon EKS User Guide2026-11-21
2Accelerate model loading on Amazon EKSAmazon EKS 사용 설명서Amazon EKS User Guide2026-11-21
3Use EKS-optimized accelerated Linux AMIs for GPU instancesAmazon EKS 사용 설명서Amazon EKS User Guide2026-11-21
4Restrict Pod network traffic with Kubernetes network policiesAmazon EKS 사용 설명서Amazon EKS User Guide2026-11-21
5Amazon EC2 G6e Instances제품 페이지Product page2026-11-21
6Restrict access with VPC originsAmazon CloudFront 개발자 안내서Amazon CloudFront Developer Guide2026-11-21
7Rate-based rule caveats in AWS WAFAWS WAF 개발자 안내서AWS WAF Developer Guide2026-11-21
8Search the web using Amazon Bedrock AgentCore Web SearchAmazon Bedrock AgentCore 개발자 안내서Amazon Bedrock AgentCore Developer Guide2026-11-21
9Set up ingestion from an existing Prometheus server in Kubernetes on EC2Amazon Managed Service for Prometheus 사용 설명서Amazon Managed Service for Prometheus User Guide2026-11-21
10NodePoolsKarpenter 문서Karpenter docs2026-11-21
11NodeClassesKarpenter 문서Karpenter docs2026-11-21
12Loading models with Run:ai Model StreamervLLM 문서vLLM docs2026-11-21
13torch.compile integrationvLLM 문서vLLM docs2026-11-21
14QuantizationvLLM 문서vLLM docs2026-11-21
15Sleep ModevLLM 문서vLLM docs2026-11-21
16Production Metrics (v0.33.0)vLLM 문서vLLM docs2026-11-21
17MTP (Multi-Token Prediction) (v0.33.0)vLLM 문서vLLM docs2026-11-21
18vllm.config.schedulervLLM API 문서vLLM API docs2026-11-21
19single_type_kv_cache_manager.py (v0.33.0)vLLM 소스vLLM source2026-11-21
20IntroductionGateway API Inference Extension 문서Gateway API Inference Extension docs2026-11-21
21Release v1.6.0Gateway API Inference Extension 릴리스 노트Gateway API Inference Extension release notes2026-11-21
22Flow Control (v1.0.0)llm-d 문서llm-d docs2026-11-21
23Multiple inference poolsagentgateway 문서agentgateway docs2026-11-21
24strands-deciderGitHub 저장소GitHub repository2026-11-21
25ow-on-gpuGitHub 저장소GitHub repository2026-11-21
26Introducing Strands Decider v2Strands Agents 블로그Strands Agents blog2026-11-26