본문 바로가기
C.W.K.
Stream
Lesson 04 of 08 · published

리전과 할당량은 출시 전에 계산해야 해

~14 min · rate-limits, quota, regions, throughput

Level 0Observer
0 XP0/64 lessons0/13 achievements
0/150 XP to next level150 XP to go0% complete

한도는 조직과 모델마다 따로 움직여

Anthropic Console의 조직에는 모델별로 분당 요청 수(RPM), 분당 입력 토큰(ITPM), 분당 출력 토큰(OTPM) 한도가 잡혀. 새 조직은 낮은 사용량 티어에서 시작하고 지출과 계정 이력에 따라 올라가. 지금 가진 한도를 모른 채 트래픽만 예상하는 건 용량 계획이 아니라 희망 사항이야.

클라우드 경로는 계산식을 다시 봐야 해

Bedrock은 AWS 계정과 리전별 할당량을 쓰고 AWS 지원을 통해 증설해. Vertex는 GCP 프로젝트별 한도를 쓰며 GCP 지원 절차를 따라. Anthropic 직접 API에서 맞춘 처리량 계산을 그대로 옮길 수 없으니, 약속할 응답량과 지연을 정하기 전에 실제 클라우드 콘솔에서 확인해야 해.

429 뒤의 행동까지 제품이 결정해

한도에 닿으면 429 Too Many Requestsretry-after 헤더가 와. SDK의 기본 재시도 범위를 넘은 요청은 애플리케이션이 책임져야 해. 지수 백오프를 할지, 큐에 넣을지, 일부를 버릴지, 더 싼 모델이나 기능으로 낮출지 미리 골라 둬. 스트리밍은 이미 일부 출력이 전달됐을 수 있으므로 처음부터 다시 보내도 안전한지 별도로 판단해야 해.

원칙: 할당량과 리전 지연은 운영 뒤에 발견할 제약이 아니라 처음부터 넣을 아키텍처 입력값이야.

Code

레이트리밋 헤더 읽기 (Python)·python
from anthropic import Anthropic

client = Anthropic()
response = client.messages.with_raw_response.create(
    model="claude-sonnet-4-6",
    max_tokens=128,
    messages=[{"role": "user", "content": "hi"}],
)
for h in (
    "anthropic-ratelimit-requests-remaining",
    "anthropic-ratelimit-input-tokens-remaining",
    "anthropic-ratelimit-output-tokens-remaining",
    "retry-after",
):
    print(h, response.headers.get(h))
SDK 헬퍼 위에 백오프 한 겹·python
from anthropic import Anthropic, RateLimitError
import time, random

client = Anthropic(max_retries=3)  # SDK가 429/5xx를 이 횟수까지 자동 재시도.

def call_with_backoff(messages, attempts=5):
    delay = 1.0
    for i in range(attempts):
        try:
            return client.messages.create(
                model="claude-sonnet-4-6",
                max_tokens=512,
                messages=messages,
            )
        except RateLimitError as e:
            wait = float(e.response.headers.get("retry-after", delay))
            time.sleep(wait + random.random())
            delay *= 2
    raise RuntimeError("exhausted backoff")

External links

Exercise

Anthropic Console에서 모델별 RPM과 TPM 한도를 적어. 각 한도를 채울 수 있는 가장 작은 입력과 대응 방식인 큐·기능 축소·배치 중 하나도 함께 써.
Hint
긴 PDF나 이미지 한 번만으로도 ITPM에 먼저 닿을 수 있어.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.