diff --git a/public/blog/cars2/backfill.png b/public/blog/cars2/backfill.png new file mode 100644 index 0000000..007d457 Binary files /dev/null and b/public/blog/cars2/backfill.png differ diff --git a/public/blog/cars2/fanout.png b/public/blog/cars2/fanout.png new file mode 100644 index 0000000..02ee19a Binary files /dev/null and b/public/blog/cars2/fanout.png differ diff --git a/public/blog/cars2/mom.png b/public/blog/cars2/mom.png new file mode 100644 index 0000000..0bd1399 Binary files /dev/null and b/public/blog/cars2/mom.png differ diff --git a/public/blog/cars2/queen.png b/public/blog/cars2/queen.png new file mode 100644 index 0000000..e5174ce Binary files /dev/null and b/public/blog/cars2/queen.png differ diff --git a/public/blog/cars2/speed2.png b/public/blog/cars2/speed2.png new file mode 100644 index 0000000..0a66b2a Binary files /dev/null and b/public/blog/cars2/speed2.png differ diff --git a/public/blog/cars2/toilet.png b/public/blog/cars2/toilet.png new file mode 100644 index 0000000..403052f Binary files /dev/null and b/public/blog/cars2/toilet.png differ diff --git a/src/pages/blog/cars2.mdx b/src/pages/blog/cars2.mdx new file mode 100644 index 0000000..e239683 --- /dev/null +++ b/src/pages/blog/cars2.mdx @@ -0,0 +1,230 @@ +--- +layout: "@/layouts/global.astro" +title: "MoQ is for the Cars" +author: kixelated +description: MoQ is like Lightning McQueen. But it's a live networking protocol, not an animatronic sports car in a fictional movie produced by Pixar Animation Studios for Walt Disney Pictures. +cover: "/blog/cars2/queen.png" +date: 2026-06-22 +--- + +# MoQ for the Cars +sup + +This is an unexpected collaboration with Fastly. +They liked the MoQ blog posts and actually sponsored me to make a [hinged version](https://www.fastly.com/blog/moq-in-the-fast-lane), cross-posted to their **OFFICIAL BLOG**. +Go read that one instead if my usual cringe is too much. + +Roses are red. 🌹 +Sports cars be too. 🚗 +MoQ be fast. 🚀 +Cars 2™ is a 2011 American animated comedy film produced by Pixar Animation Studios for Walt Disney Pictures. + +
+ ![mah boy, Lightning McQueen](/blog/cars2/queen.png) +
starring Lightning McQueen, the devilishly handsome race car
+
+ +## Cars 2: Electric Boogaloo +Lightning McQueen is racing around the track. +The spectators in the stands are honking wild. +**HONK HONK** + +But we don't care about the stans in the stands. +We care about the cars in their garage? +The ones willing to pay big bucks if we can transmit the **LOUD CARS DO CIRCLES** race over the internet. +Or whatever currency cars use, IDK I'm not a lore expert. + +The answer for the last decade has been HLS/DASH. +Split the media into fragments, anywhere from 0.5s to 4s long, and serve them over HTTP. +It's boring but it works. + +But just like the Mini Cooper, [there are a few short-comings](https://moq.dev/blog/replacing-hls-dash). +- Flushing media in batches **adds latency** (0.5s to 4s). +- Network congestion causes head-of-line blocking and **the spinny boye**. +- Every second of the spinny boye means **even more latency**. + +This is why I created MoQ while at Twitch. +The goal was to make live streams more interactive (and less boring). +**Stream frames, and occasionally drop instead of blocking.** + +High latency is for losers. +I always finish first, just like Lightning McQueen. + + + +## MoQ for the Fans +First, I wanted to address the SUV in the room. +My previous blog post, [You Don't Need It](https://moq.dev/blog/you-dont-need-it/), mentioned that you don't need MoQ for high-quality content. +It's true, but *as always*, there are exceptions to my shitty opinions. + +But before we disprove one shitty opinion, we need to prove another. +**Racing is boring**. + +The video footage is **so boring** that the only thing separating two laps is a counter. +Like yes, sometimes the car goes boom, but there's so much dead air. +I postulate that you're watching to be part of the story **LIVE**, not to see every millisecond of lap 392 in the Toilet Bowl 500. + +And it might actually be a good use-case for MoQ. +Because instead of buffering/pausing to load boring content, we can instead skip it to keep latency low. +It keeps you in the action with **sub-second latency**. +And milliseconds might be the difference between winning and losing. + +**FUN FACT**: Sports ~betting~ prediction markets are a thing. Degenerate users love lower latency. + +
+ ![speedometer](/blog/cars2/speed.png) +
gotta go fast
+
+ +And before you get your suspension in a twist, MoQ can still provide the same quality/latency you expect from HLS/DASH. +We just lower the latency floor for the Lightning McQueens out there who want to **WIN**. + + +## MoQ for the Cars +I originally made MoQ [for the fans](/blog/distribution-at-twitch). +But people keep running my code on the cars. +[Or the boats](/blog/on-a-boat). + +TBH, this is the better use-case for MoQ. + +You might have pieced together that I don't watch racing (**boring**) outside of critically acclaimed movies for children. +Starring Lightning McQueen and his goofy comrades, the cars go fast vroom vroom. +But when I do see snippets of F1, the camera feeds from the cars are **awful**. + +Me, the uninformed dumbass, has a hunch that it's due to networking. +There's going to be deadzones or interference or whatever around the track. +We are bound by the laws of physics, even in the Cars 2 Cinematic Universe. + +> We no can send all bytes. +\- Lightning McQueen (2011) + +**Boring protocols** like RTP drop packets/frames based on SLAs. +The publisher gives up (re)transmitting a frame after ~100 milliseconds; then it's gone forever. +This often shows up as artifacting or tearing or frozen video. + +But **the chad protocol** doesn't give up. + +MoQ publishers **prioritize transmitting the newer stuff** (in dependency order). +The old stuff gets **queued in RAM** (up to a TTL). +When bandwidth recovers, we can **backfill old footage** instead of losing it forever. + +Each MoQ subscriber independently decides how long to wait for each frame: +- The **live stream** might wait for up to 1 second +- The **instant relay** might wait for up to 10 seconds +- The **VOD recording** might wait for up to 1 minute. + +So your real-time feed might be lossy af, but the VOD is pristine. + +
+ ![Realtime vs Backfill](/blog/cars2/backfill.png) +
If I ever own a racing team, it's going to be called The Backfill Boyes
+
+ +The packets may have given up. But Lightning McQueen never gives up. +He always finishes first and the crowd goes **HONK HONK**. + + +## MoQ for the Robots +We're closer to the Cars Cinematic Universe than we want to admit. +Humans are a dying breed. +Like a pug on a hot day. +**RIP us.** + +Enter the robots. +They byte. +And they need networking for their bleeps and bloops. +It turns out that MoQ works for more than just media: +- The speedometer? **A live stream**. +- The steering wheel? **A live stream**. +- The G force sensor as Lightning McQueen heroically crashes into a wall to save the day? **A live stream**. + +Seriously, there's nothing special about media. +It's just delta encoded data. +You can delta encode a lot of things, [even JSON](https://datatracker.ietf.org/doc/html/rfc7386). +Just like I delta encoded your mom last night. + +
+ ![ur mom joke](/blog/cars2/mom.png) +
yes, a ur mom joke in ``
+
+ +Networks aren't infinite. +So we split up media into tracks/groups/frames/packets so pieces can be dropped when needed. +The reality is that some bytes are just less valuable than others. +We can't all be Lightning McQueen. + +The hard part is putting humpty back together. +That's why we use timestamps baybee, they tell us when stuff happened relative to other stuff. +So do the same thing for metadata. +Stamp that fellow, using the same clock as media, and send it over the same pipe. + +You can, and should, take the red pill and use MoQ for **EVERYTHING**. +A single **cooperative** QUIC connection with: `controls > audio > metadata > video` + +**FUN FACT**: MoQ is already being used remotely to pilot drones over Starlink. +One day we'll be able to remotely drive Lightning McQueen. + +And yes, this sounds simple but it's something WebRTC completely botches. +You have to use a separate connection for metadata and timestamps aren't exposed in the browser. + + +## MoQ for the Track +We're not done yet. +Sit back in your seat. +Fasten that seatbelt. +It's the law, and I'm the sheriff from the critically acclaimed movie Cars 2. + +Yeah I know the joke is overdone. +Give me a pitty chuckle, we're almost done. + +If more than one broadcast studio wants footage of Lightning McQueen's tailpipe, we don't want to transmit multiple copies. +Our satellite truck is expensive and has a limited bandwidth budget. + +And what if none of the broadcast studios actually want that hot, smokey, tailpipe footage? +Do we even want to transmit it, or is it just a waste of bandwidth? +With all of this data swirling around the track, there has to be some way to organize it. + +Enter stage right: **moq-relay** + +It's a simple proxy that connects **1 publisher** with **N subscribers** (per broadcast/track). +When **moq-relay** instances connect to each other, they automatically form a cluster. +It handles discovery, routing, and proxying. + +You can host it yourself [and/or pay me](https://pro.moq.dev). For example: +- **Lightning McQueen** connects to a self-hosted moq-relay at `192.168.420.69`. +- **moq-relay** is run with `--cluster-connect https://cdn.moq.dev/cars2`. +- **Studio clients** (or a relay!) connects to `https://cdn.moq.dev/cars2`. + +Just like a tinder hookup, there's a match and now you're the sub. +Any broadcasts published by Lightning McQueen are automatically available to all relays, potentially proxied through multiple hops. + +And only one copy is ever transmitted between each **moq-relay** instance, regardless of the number of downstream subscribers. +This is known colloquially as "big deal" when flakey venue internet and expensive satellite trucks are involved. +Run a self-hosted relay at each track, aggregate all of the feeds automatically, and publish them to a CDN. + +
+ ![moq-relay fanout](/blog/cars2/fanout.png) +
literally infinite viewers from a single, semi-reliable feed
+
+ +And there's no limit to the number of connections you can establish. +[moq-lite](https://doc.moq.dev/concept/layer/moq-lite.html) routes each subscription over the shortest path. +Go ahead, connect to `cdn.moq.dev` and `cloudflare.mediaoverquic.com` at the same time; they sit idle until someone subscribes. + +It's like swiping right on Lightning McQueen multiple times on alt accounts. +Don't judge. + + +## Disclaimer +I hope you've realized by now that I haven't seen the critically acclaimed movie Cars 2. +That poster of Lightning McQueen on my wall is just part of the gag. +I stare at it quite often to keep up the ruse. + +Thanks again to Fastly for sponsoring this post. +They just told me to write something about MoQ, so I did. +No refunds. + +If you're interested in more Cars 2 lore, join the [fan club](https://discord.gg/FCYF3p99mr) or email me at `me@kixel.me`. + +Written by [@kixelated](mailto:meself@kixel.me). +![@kixelated](/blog/avatar.png)