백프레셔와 부하 조절 패턴
OTP 기본 요소를 기반으로 한 백프레셔, 속도 제한, 부하 차단 패턴을 사용해 과부하 상황에서도 시스템을 안정적으로 유지하는 방법을 배웁니다.
백프레셔와 부하 조절 패턴은(는) CoddyKit의 무료 Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Erlang OTP: Distributed & Fault-Tolerant Systems Programming 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
What Is Backpressure?
When work arrives faster than a system can process it, queues grow and latency explodes. Backpressure is the practice of signalling producers to slow down so the system stays stable instead of melting down.
The Unbounded Queue Problem
An async gen_server:cast never blocks the caller, so its mailbox can grow without limit under load — the system runs out of memory before it ever rejects work.
Synchronous Calls as Backpressure
Using gen_server:call instead of cast makes the caller wait until the server is ready, naturally throttling producers to the server speed.
Reply = gen_server:call(worker, {process, Job}, 5000).Bounded Queues
Maintain an explicit counter of in-flight work and reject or block new requests once a limit is reached, rather than letting the mailbox grow.
handle_call({job, J}, _From, #{n := N} = S) when N < 100 ->
{reply, ok, S#{n := N + 1}};
handle_call({job, _}, _From, S) ->
{reply, {error, overloaded}, S}.Load Shedding
Under extreme load, the best move can be to shed low-priority work fast — returning an error immediately — to protect the system for high-priority requests.
Rate Limiting with Tokens
A token-bucket limiter grants a fixed number of permits per interval; requests beyond that wait or fail. This caps throughput predictably.
case take_token(Bucket) of
ok -> do_work();
empty -> {error, rate_limited}
end.Measuring Pressure
The mailbox length of a bottleneck process is a live pressure gauge. Monitor it and trigger shedding before it grows dangerous.
process_info(Worker, message_queue_len).Pooling for Throughput
A pool of worker processes (e.g. via poolboy) bounds concurrency: requests queue for a free worker, giving natural backpressure with controlled parallelism.
Circuit Breakers
When a downstream dependency is failing, a circuit breaker opens to stop sending requests for a cooldown period, preventing pileups and giving the dependency time to recover.
Timeouts as Protection
Always give gen_server:call a finite timeout. An unbounded wait lets a stuck server block callers indefinitely; a timeout converts a hang into a fast, recoverable error.
case catch gen_server:call(srv, req, 2000) of
{ok, R} -> R;
_ -> {error, busy}
end.Choosing a Strategy
Combine patterns: synchronous calls for natural throttling, bounded queues to cap memory, rate limiting for fairness, and load shedding plus circuit breakers as last-resort protection.
Quick Check
Test your load regulation knowledge.
Recap
You learned to keep systems stable under overload:
- Backpressure signals producers to slow down
- Synchronous
callthrottles naturally; bounded queues cap memory - Rate limiting enforces fairness; load shedding protects priority work
- Worker pools bound concurrency; circuit breakers stop downstream pileups
- Monitor mailbox length as a live pressure gauge
자주 묻는 질문
“백프레셔와 부하 조절 패턴” 강의는 무료인가요?
네 — “백프레셔와 부하 조절 패턴” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의 전체를 잠금 해제할 수 있습니다. Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의에는 총 4개의 강의가 포함되어 있습니다.
“백프레셔와 부하 조절 패턴”에서 뭘 배우나요?
OTP 기본 요소를 기반으로 한 백프레셔, 속도 제한, 부하 차단 패턴을 사용해 과부하 상황에서도 시스템을 안정적으로 유지하는 방법을 배웁니다. 브라우저에서 직접 실행하는 실습 코드로 Erlang OTP: Distributed & Fault-Tolerant Systems Programming을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Erlang OTP: Distributed & Fault-Tolerant Systems Programming을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Erlang OTP: Distributed & Fault-Tolerant Systems Programming은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“백프레셔와 부하 조절 패턴” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Erlang OTP: Distributed & Fault-Tolerant Systems Programming 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 고가용성을 위한 설계
- 분산 합의 패턴
- Erlang OTP 사례 연구
- 백프레셔와 부하 조절 패턴