부하 분산과 서비스 검색
부하 분산기, 상태 점검, 서비스 검색을 사용해 SaaS 백엔드가 여러 인스턴스에 트래픽을 분산하는 방식을 이해합니다.
부하 분산과 서비스 검색은(는) CoddyKit의 무료 SaaS Architecture & Startup Engineering 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 SaaS Architecture & Startup Engineering 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. SaaS Architecture & Startup Engineering 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
The Need for Load Balancing
When one server cannot handle all traffic, you run many copies. A load balancer sits in front and spreads incoming requests across these instances.
This is the backbone of horizontal scaling for SaaS backends.
How a Load Balancer Works
Clients connect to a single address. The load balancer accepts the request and forwards it to one of the backend servers, then relays the response back.
To the client, the cluster looks like one powerful server.
Round Robin
The simplest algorithm is round robin: requests are handed to servers in rotation. Each server gets an equal share.
const servers = ['s1', 's2', 's3'];
let i = 0;
function next() {
const s = servers[i % servers.length];
i++;
return s;
}
console.log(next(), next(), next(), next());Least Connections
Least connections routes each new request to the server currently handling the fewest active connections.
This adapts better than round robin when requests have uneven durations.
Layer 4 vs Layer 7
Load balancers operate at different network layers:
- Layer 4 (transport) — routes by IP and port, very fast
- Layer 7 (application) — inspects HTTP, can route by URL path or headers
Layer 7 enables smart routing like sending /api to one pool and /static to another.
Health Checks
A load balancer must avoid sending traffic to dead servers. It runs periodic health checks against each instance.
A common pattern is a /health endpoint returning 200 OK when the app is ready.
app.get('/health', (req, res) => {
res.status(200).json({ status: 'ok' });
});Sticky Sessions
Some apps store session state in server memory. Sticky sessions pin a client to the same server so their session persists.
Better practice: keep servers stateless and store sessions in a shared store, so any server can handle any request.
Service Discovery
In dynamic environments, servers come and go constantly. Service discovery keeps an up-to-date registry of which instances exist and are healthy.
Tools like Consul, etcd, or Kubernetes services automate this.
Client-Side vs Server-Side Discovery
Two models:
- Server-side — clients hit a load balancer that consults the registry
- Client-side — clients query the registry directly and pick an instance themselves
Server-side is simpler; client-side reduces a network hop.
Autoscaling Integration
Load balancers pair with autoscaling: when traffic rises, new instances spin up, register with discovery, and the balancer starts routing to them automatically.
When traffic drops, instances are removed gracefully after draining connections.
Graceful Draining
Before shutting down an instance, the balancer should stop sending new requests but let existing ones finish. This is connection draining.
It prevents dropped requests during deployments and scale-down events.
Quick Check
Test your load balancing knowledge.
Recap
You learned how SaaS backends distribute traffic:
- Load balancers with round robin and least connections
- Layer 4 vs Layer 7 routing and health checks
- Stateless design, service discovery, and graceful draining
Together these let a backend scale horizontally and survive failures.
자주 묻는 질문
“부하 분산과 서비스 검색” 강의는 무료인가요?
네 — “부하 분산과 서비스 검색” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 SaaS Architecture & Startup Engineering 강의 전체를 잠금 해제할 수 있습니다. SaaS Architecture & Startup Engineering 강의에는 총 4개의 강의가 포함되어 있습니다.
“부하 분산과 서비스 검색”에서 뭘 배우나요?
부하 분산기, 상태 점검, 서비스 검색을 사용해 SaaS 백엔드가 여러 인스턴스에 트래픽을 분산하는 방식을 이해합니다. 브라우저에서 직접 실행하는 실습 코드로 SaaS Architecture & Startup Engineering을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
SaaS Architecture & Startup Engineering을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 SaaS Architecture & Startup Engineering은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.
“부하 분산과 서비스 검색” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 SaaS Architecture & Startup Engineering 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 SaaS Architecture & Startup Engineering 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 수평 확장 기법
- 메시지 큐 및 이벤트 기반 아키텍처
- 서버리스 아키텍처 기초
- 부하 분산과 서비스 검색