Latest / The CTO Podcast with Fexingo: Technical Leadership, Architecture, and Engineering Org / How Spotify Cut Streaming Costs by 30 Percent with a Smarter Codec
Transcript
- Lucas: So, Spotify quietly made a change a few years back that most listeners never noticed, but it saved them a fortune. They switched their default streaming codec from Ogg Vorbis to Opus. Luna: And that's a big deal? I mean, I know codecs matter for quality, but how much money are we talking? Lucas: Spotify said it saved about 30 percent on their streaming bandwidth costs. With over 500 million users, that's hundreds of millions of dollars a year. And it wasn't just about cost—it was about making the service better for people on slower connections. Luna: Okay, so tell me exactly what a codec does. In simple terms, it's like the language that audio is translated into for streaming, right? Lucas: Exactly. A codec takes the original audio file and compresses it so it can travel over the internet more efficiently. The trade-off is always between file size and audio quality. A better codec can deliver the same quality at a lower bitrate, which means smaller files and less bandwidth. Lucas: Opus is an open-source codec that's particularly good at that. It was designed for real-time communication, like voice calls, but it's also excellent for music. So Spotify switched their default stream from Ogg Vorbis at 160 kilobits per second to Opus at 96 kilobits per second—and they actually improved perceived audio quality. Luna: Wait, they lowered the bitrate but the quality went up? How is that possible? Lucas: Because Opus is just a more efficient codec. It uses more sophisticated algorithms to decide what audio data to keep and what to throw away. So at the same bitrate, it sounds better than older codecs. And at a lower bitrate, it can still sound as good as a higher-bitrate stream in the old codec. Luna: That's clever. But I imagine there's a catch. Why didn't they do this earlier? Lucas: The main issue was device compatibility. Opus is relatively new, and older devices—especially some car audio systems and smart speakers—didn't support it. So Spotify had to keep a fallback to Ogg Vorbis for those devices. That means they're running a dual-codec system, which adds complexity to their infrastructure. Lucas: But over time, as more devices added Opus support, they could shift more traffic to the more efficient codec. It's a migration story, not a flip the switch moment. Luna: And that dual-codec system—how do they decide which codec to use for a given user? Lucas: They have a negotiation process. When your device connects to Spotify, it tells the server what codecs it supports, and the server picks the best one. So if you're on a modern smartphone, you'll likely get Opus. If you're on an older car audio system, you might get Ogg Vorbis. Luna: So it's like a handshake between the client and the server, choosing the most efficient language they both speak. Lucas: Right. And this is a classic CTO decision—weighing the long-term benefits of a new technology against the short-term pain of supporting two versions. Spotify chose to eat that complexity for years, and now it's paying off. Luna: But the cost savings are just one part. What about the user experience? Did anyone notice a difference in quality? Lucas: Most people couldn't tell the difference in blind tests, and in some cases, Opus at 96 kilobits actually sounded better than Vorbis at 160. So Spotify improved the experience for people with slow connections, reduced buffering, and made their app use less data—which is a big deal for mobile users with data caps. Lucas: And there's a battery benefit too—fewer bits to download means less power used by the network radio, especially on cellular. So it's a win across the board. Luna: So this is an example of a seemingly technical choice that has huge business impact. I think that's what our listeners really want to hear about—how to think about these kinds of decisions. Lucas: Exactly. And it's not just about codecs. The principle applies to any data-heavy service. If you can make your data smaller without sacrificing user experience, you save money and improve the service at the same time. Luna: Like how Netflix compresses video differently for different connection speeds. Lucas: Yeah, that's the same idea. They're constantly tuning their encoding parameters based on the content and the user's network. This is the kind of optimization that separates a well-run engineering org from one that just throws hardware at the problem. Lucas: And it's not just about reducing costs. It's about being responsible with resources. Streaming music is a massive industry, and every kilobyte matters when you're serving millions of songs every second. Luna: I never thought about the environmental angle, but yeah, less bandwidth means less energy used by servers and networks. So it's a sustainability win too. Lucas: That's a good point. And that's something we care about here—these conversations are about making tech better, not just for the bottom line, but for the world. If these conversations are useful for what you're building or running, you might want to support the show. We deliberately don't run ads on these, and if you want to keep it that way, the link is buy me a coffee dot com slash fexingo. Luna: Yeah, it's a small way to say thanks for the insights. And we appreciate anyone who does. Lucas: Alright, back to codecs. So, Spotify's move is a great case study, but let's talk about what other CTOs can learn from it. The first lesson is to keep an eye on emerging standards. Opus wasn't a secret, but it took a while for it to be viable. Spotify was early to adopt it. Luna: How early were they? Lucas: They started experimenting with it years before the format was widely supported. The key was that they built a system that could support multiple codecs from the start, so they could test and roll out Opus incrementally. Lucas: Another lesson is the importance of measuring. Spotify has telemetry that tracks audio quality in real time. They could see that Opus was performing well and that users weren't complaining about quality. So they had data to back up the switch. Luna: So it's not just about picking the right tech, but about having the metrics to prove it's working. Lucas: Exactly. And that's a theme we've seen across many episodes—whether it's Cloudflare's edge network or Stripe's idempotency. The CTO's job is to make informed bets, and that requires good data. Luna: What about the risk? Were there any downsides to the switch? I imagine there might have been some edge cases. Lucas: Sure, there were edge cases. Some older devices had bugs in their Opus decoders, so Spotify had to work around those. But they had a fallback, so it wasn't a disaster. They could A/B test and slowly ramp up the percentage of users on Opus. Lucas: This is a pattern we see in many engineering orgs—canary releases, feature flags, gradual rollouts. The codec switch was just another feature, albeit one that affects every stream. Luna: So what's the takeaway for a CTO at a smaller company? Is this something they can do too? Lucas: Absolutely. Even if you're not streaming music, you're probably moving data around. If you can compress it better, you save money on bandwidth and storage. And you might even improve user experience if your users are on slow connections. Lucas: The key is to not wait until it's urgent. Start experimenting with new codecs or compression algorithms now, and measure the impact. You might be surprised at the savings. Luna: And it's not just about codecs—it's about any kind of efficiency. Like using better data formats or caching more aggressively. Lucas: Right. The principle is universal: reduce the amount of data you have to move, and you'll save money and energy. It's a classic engineering mindset that pays off in the long run. Luna: I love that this episode gives us a concrete number—30 percent cost savings. That's something I can tell a friend at a dinner party. Lucas: And that's the beauty of these engineering stories. They're not just about tech—they're about business outcomes. I think that's why we love doing this show. Luna: So, next time you're listening to a song on Spotify, you know there's some serious engineering behind making it sound great and not bankrupting the company. Lucas: Absolutely. And it's not just Spotify—it's every company that streams high-quality media. They're all fighting the same battle, and the ones that win are the ones that make the smartest trade-offs.