Backend System Design

Protocol Scenarios

Jem Young
Netflix
Backend System Design

Lesson Description

The "Protocol Scenarios" Lesson is part of the full, Backend System Design course featured in this preview video. Here's what you'd learn in this lesson:

Jem walks students through protocol scenarios, comparing WebSockets and HTTP for real-time updates and trade-offs like battery use. He discusses which protocols suit each case, using examples such as REST for banking APIs and gRPC for microservices and video processing.

Preview

Transcript from the "Protocol Scenarios" Lesson

[00:00:00]
>> Jem Young: I could make this exercise, but let's make it collaborative just to reinforce. I have a stock trading dashboard showing real-time price updates. What should I use? What do you think I should use? Server-Sent Events, yeah, yeah, that's what I would use. I'm building collaborative document editors, so something like Google Docs. WebSockets, yeah, it's going to be back and forth, but it still needs to be real-time.

[00:00:29]
Uh, food delivery app that needs to show the driver's location. I guess it depends on how often you need to update that. Is it one direction or two? Hmm, I like where you're going, Kayla. Let's think about it. So what are we trying to figure out, where the driver is? So there's a user that's getting a read, and then the driver's probably doing her write, but those are single directions differently.

[00:01:06]
Yeah, because I was going to say, I guess the way I'm thinking about it is that if it doesn't need to update that often, we could probably just do standard HTTP every couple of seconds, but then if it really is important that it happens very, very often, probably WebSockets. Yeah, maybe server-side, you don't have a server like the client has to send the data. Yeah, on the write, it could be HTTP.

[00:01:35]
On the read, it could be the other way. You could use gRPC if it's there. We can over-engineer everything. It's a great use case for gRPC. There is one downside about WebSockets we didn't talk about, which is there's a cost to maintaining that connection. It eats up your battery very quickly. If you ever implemented WebSockets on your mobile device, why is my battery going down? Because it's constantly pinging the backend to keep that connection alive and doing the handshake.

[00:02:04]
So in that case, Michael, you said it, HTTP long polling is a great middle ground. If you've done long polling, you're going to have thoughts on it, but it's a middle ground. Probably get some flak for that one. An API for a banking system used by multiple client applications. So think a third-party API. Yeah, I'd go to REST. That one, you know, you say, oh, GraphQL because the schema is well-defined, but REST is pretty, pretty rock solid.

[00:02:42]
There's not a high learning curve on REST. You can pick that up in a day or two. I shouldn't say these sort of things, because maybe it's hard. Yeah, I'd go to REST. Communication between microservices and a video processing pipeline, yeah, it's kind of a gimme.

Learn Straight from the Experts Who Shape the Modern Web

  • 250+
    In-depth Courses
  • Industry Leading Experts
  • 24
    Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now