0Pricing
Real-Time Streaming Systems (WebRTC + Live Data) · 강의

룸과 Redis를 활용한 시그널링 확장

룸 기반 메시지 라우팅과 Redis pub/sub 어댑터를 사용해 WebRTC 시그널링 서버를 수평 확장하고 서로 다른 서버 인스턴스의 피어도 연결할 수 있게 합니다.

룸과 Redis를 활용한 시그널링 확장은(는) CoddyKit의 무료 Real-Time Streaming Systems (WebRTC + Live Data) 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Real-Time Streaming Systems (WebRTC + Live Data) 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Real-Time Streaming Systems (WebRTC + Live Data) 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

One Server Is Not Enough

You have built, deployed, and tested a signaling server. As users grow, a single instance becomes a bottleneck. This lesson covers scaling signaling horizontally across multiple instances using rooms and Redis.

The Room Concept

Signaling messages should only reach the right peers. A room groups the participants of one call so offers, answers, and ICE candidates are routed only to members of that room.

Joining a Room

When a client connects, it joins a room identified by a call id. The server tracks which sockets belong to which room.

io.on('connection', (socket) => {
  socket.on('join', (roomId) => {
    socket.join(roomId);
    socket.to(roomId).emit('peer-joined', socket.id);
  });
});

Routing Within a Room

Signaling messages are relayed only to other members of the sender's room, never broadcast to everyone.

socket.on('signal', ({ roomId, data }) => {
  socket.to(roomId).emit('signal', { from: socket.id, data });
});

The Multi-Instance Problem

With several server instances behind a load balancer, two peers in the same call may connect to different instances. Instance A does not know about a room member on instance B, so signaling fails.

Pub/Sub to the Rescue

A shared Redis pub/sub layer lets instances forward messages to each other. When instance A emits to a room, Redis publishes it so instance B delivers it to its local members.

Adding the Redis Adapter

Socket.IO offers a Redis adapter that handles cross-instance routing transparently, so your room code stays unchanged.

const { createAdapter } = require('@socket.io/redis-adapter');
const { createClient } = require('redis');

const pub = createClient({ url: 'redis://localhost:6379' });
const sub = pub.duplicate();
await Promise.all([pub.connect(), sub.connect()]);
io.adapter(createAdapter(pub, sub));

Sticky Sessions

For long-lived WebSocket connections, configure the load balancer for sticky sessions so a client stays on one instance for the life of its connection, avoiding handshake breakage.

Tracking Presence

Store room membership in Redis so any instance can answer who is in a call and clean up when a client disconnects.

socket.on('join', async (roomId) => {
  await pub.sAdd('room:' + roomId, socket.id);
});
socket.on('disconnect', async () => {
  // remove from all rooms it belonged to
});

Handling Disconnects

Notify remaining peers when someone leaves so they can tear down the corresponding peer connection cleanly.

socket.on('disconnect', () => {
  socket.rooms.forEach((roomId) => {
    socket.to(roomId).emit('peer-left', socket.id);
  });
});

Scaling Strategy Summary

To scale signaling: group peers into rooms, run multiple stateless instances, connect them with a Redis adapter, enable sticky sessions, and track presence in Redis. The signaling layer then grows horizontally while calls keep connecting.

Quick Check

Test your understanding of scaling signaling.

Recap

You learned to scale signaling:

  • Rooms route messages only to call participants
  • Multiple instances need a Redis pub/sub adapter to share rooms
  • Sticky sessions keep WebSocket connections stable
  • Presence tracking and disconnect handling keep state consistent

This architecture supports many concurrent calls reliably.

자주 묻는 질문

“룸과 Redis를 활용한 시그널링 확장” 강의는 무료인가요?

네 — “룸과 Redis를 활용한 시그널링 확장” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Real-Time Streaming Systems (WebRTC + Live Data) 강의 전체를 잠금 해제할 수 있습니다. Real-Time Streaming Systems (WebRTC + Live Data) 강의에는 총 4개의 강의가 포함되어 있습니다.

“룸과 Redis를 활용한 시그널링 확장”에서 뭘 배우나요?

룸 기반 메시지 라우팅과 Redis pub/sub 어댑터를 사용해 WebRTC 시그널링 서버를 수평 확장하고 서로 다른 서버 인스턴스의 피어도 연결할 수 있게 합니다. 브라우저에서 직접 실행하는 실습 코드로 Real-Time Streaming Systems (WebRTC + Live Data)을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Real-Time Streaming Systems (WebRTC + Live Data)을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Real-Time Streaming Systems (WebRTC + Live Data)은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.

“룸과 Redis를 활용한 시그널링 확장” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Real-Time Streaming Systems (WebRTC + Live Data) 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Real-Time Streaming Systems (WebRTC + Live Data) 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 시그널링 백엔드 선택
  2. 시그널링 로직 구현
  3. 시그널링 배포 및 테스트
  4. 룸과 Redis를 활용한 시그널링 확장
← Real-Time Streaming Systems (WebRTC + Live Data)(으)로 돌아가기