สถาปัตยกรรม SFU เทียบกับ MCU
ทำความเข้าใจความแตกต่างระหว่างหน่วยส่งต่อแบบเลือก (SFU) และหน่วยควบคุมหลายจุด (MCU) สำหรับการโทร WebRTC หลายฝ่าย
สถาปัตยกรรม SFU เทียบกับ MCU เป็นบทเรียน Real-Time Streaming Systems (WebRTC + Live Data) ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Real-Time Streaming Systems (WebRTC + Live Data) และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Real-Time Streaming Systems (WebRTC + Live Data) มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Scaling Multi-Party Calls
Imagine a video call with many people. How do all their video and audio streams connect efficiently? Direct peer-to-peer connections, common in 1-on-1 WebRTC, become complex and inefficient for larger groups.
This lesson explores two main server-side architectures for scaling multi-party calls: MCU and SFU.
Introducing the MCU
MCU stands for Multipoint Control Unit. Think of an MCU as a central 'mixer' for all participants' media streams.
In an MCU architecture, every participant sends their individual audio and video stream to a central server.
How MCU Processes Streams
The MCU server receives all individual streams, decodes them, mixes them together into a single composite stream (e.g., a grid layout of videos), and then re-encodes this single stream.
Finally, the MCU sends this *single, mixed stream* back to *all* participants.
MCU: Client Benefits
A big advantage of the MCU model is that each client only needs to send one stream (their own) and receive one stream (the mixed stream from the server).
This significantly reduces the client's bandwidth and processing requirements, making it suitable for users with weaker internet connections or less powerful devices.
MCU: Server Trade-offs
While beneficial for clients, MCUs place a heavy load on the server. The server has to decode, mix, and re-encode many streams in real-time.
- Server Intensive: High CPU and memory usage.
- Quality Compromise: Re-encoding can introduce latency and reduce individual stream quality.
- Limited Customization: Clients receive a fixed layout determined by the server.
Introducing the SFU
SFU stands for Selective Forwarding Unit. Unlike an MCU, an SFU does not mix or re-encode media streams.
An SFU acts as a smart router, forwarding individual streams from one participant to all others who need to receive them.
How SFU Routes Streams
In an SFU setup, each participant sends their stream to the SFU server. The SFU then forwards each participant's stream *individually* to all other participants.
The SFU can selectively choose which streams to forward and at what quality (e.g., sending a lower resolution to clients with poor bandwidth).
SFU: Client-Side Flexibility
With an SFU, each client receives multiple individual streams (one from each other participant). The client then decodes and renders these streams locally.
This allows for greater flexibility in layout and individual stream control on the client side. For example, a client can choose to display only a few main speakers.
Try running this example:
function simulateSFUClient(numberOfParticipants) {
console.log("--- SFU Client Simulation ---");
console.log("Receiving individual streams from server:");
for (let i = 1; i <= numberOfParticipants; i++) {
console.log(` - Stream ${i} (from Participant ${i})`);
// In a real WebRTC app, this would involve
// creating a <video> element for each stream.
}
console.log("Client renders all streams locally.");
console.log("----------------------------");
}
simulateSFUClient(3); // Simulate a call with 3 other participantsSFU: Balancing Act
SFUs are highly efficient for the server as they don't decode/re-encode, just forward. This makes them more scalable for many participants.
However, clients need more bandwidth (to receive multiple streams) and more processing power (to decode and render them all locally).
- Server Efficient: Low CPU/memory per stream.
- Client Intensive: Higher bandwidth and CPU for clients.
- Flexible: Clients can customize layout and individual stream visibility.
Choosing the Right Architecture
The choice between MCU and SFU depends on your application's specific needs:
- MCU: Best for low-bandwidth clients, fixed layouts, and when server cost for processing is acceptable.
- SFU: Ideal for high-quality, flexible layouts, and when scaling to many participants is critical, assuming clients have adequate resources.
SFU vs. MCU Quiz
Test your understanding of MCU and SFU architectures.
Recap: MCU vs. SFU
We've explored two key architectures for multi-party WebRTC calls:
- MCU (Multipoint Control Unit): Server mixes streams, sends one composite stream to each client. Good for low-resource clients, but server-intensive.
- SFU (Selective Forwarding Unit): Server forwards individual streams to clients. Offers better quality and client flexibility, but requires more client bandwidth and processing.
Choosing between them depends on your specific application requirements and user constraints for scalability and quality.
เรียนรู้ Real-Time Streaming Systems (WebRTC + Live Data) ด้วย AI tutor — ฟรี
เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป
- คอร์ส
- 12
- บทเรียน
- 48
คำถามที่พบบ่อย
บทเรียน “สถาปัตยกรรม SFU เทียบกับ MCU” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “สถาปัตยกรรม SFU เทียบกับ MCU” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Real-Time Streaming Systems (WebRTC + Live Data) ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Real-Time Streaming Systems (WebRTC + Live Data) มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “สถาปัตยกรรม SFU เทียบกับ MCU”
ทำความเข้าใจความแตกต่างระหว่างหน่วยส่งต่อแบบเลือก (SFU) และหน่วยควบคุมหลายจุด (MCU) สำหรับการโทร WebRTC หลายฝ่าย คุณปฏิบัติ Real-Time Streaming Systems (WebRTC + Live Data) ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Real-Time Streaming Systems (WebRTC + Live Data) หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Real-Time Streaming Systems (WebRTC + Live Data) บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน
บทเรียน “สถาปัตยกรรม SFU เทียบกับ MCU” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Real-Time Streaming Systems (WebRTC + Live Data) นี้ได้ไหม
ได้ บทเรียน Real-Time Streaming Systems (WebRTC + Live Data) ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- สถาปัตยกรรม SFU เทียบกับ MCU
- การกระจายภาระงานของเซิร์ฟเวอร์ส่งสัญญาณ
- บริการ STUN/TURN แบบกระจาย
- การต่อ SFU แบบหลายชั้นเพื่อรองรับการขยายตามภูมิศาสตร์