Monolith Strikes Back: How PrimeVideo Slashed Costs by 90%

Monolith Strikes Back: How PrimeVideo Slashed Costs by 90%
Monolith worshippers - Generated by Microsoft Image Creator

Last week, I stumbled upon an article that made me do a double-take: a case study about how the PrimeVideo team cut their service running costs by a whopping 90% by moving away from serverless microservices to a monolithic application! Can you believe it?

Picture your favorite superhero changing allegiances! It's somewhat unexpected that AWS, a champion of microservices, would share a study highlighting the advantages of monolithic architecture. This surprising move by AWS comes at a time when customers are diligently managing their expenses, making the article seem somewhat counterintuitive.

But as shocking as it was, it actually showcases AWS's commitment to their "your success is our success" mantra and their customer-first approach. So, here's to AWS for keeping it real and staying true to their word!

So, let's take a trip down memory lane and revisit the eternal battle between monoliths and microservices, and learn how PrimeVideo turned things around by going against the grain.

Monolith vs. Microservices: The Clash of the Titans

First, let's address the elephant in the room.

Monoliths have their charm: they're simple, easy to maintain, and perfect for small teams or projects with limited complexity. But when it comes to scaling, they can be as stubborn as a mule.

Microservices, the cool kid on the block, are flexible and scalable, making them the go-to choice for larger teams or projects with complex and evolving requirements. They enable continuous deployment and resilience, but like any cool kid, they have their issues – higher operational overhead, longer development times, and increased complexity.

The ultimate decision? It depends on factors like team size, project complexity, system criticality, and scalability needs. There's no one-size-fits-all here.

Back to PrimeVideo's Great Adventure

Every new application starts as an experiment. You need to be able to pivot quickly, fail fast, and adjust as the unforeseen dictates the product. That's where serverless really shines – it's perfect for launching new products and experimenting without worrying about infrastructure management.

But, as the saying goes, "there's no such thing as a free lunch." As usage grows, so do the overhead costs of running serverless.

Growing Pains: Time to Address the Bottlenecks

PrimeVideo soon realized that some components were causing them to hit a hard scaling limit.

Marcin Kolny, Senior SDE at Prime Video, explained, "To address the bottlenecks, we initially considered fixing problems separately to reduce cost and increase scaling capabilities."

The solution? A bold decision to rearchitect their infrastructure, and it paid off.

"The main scaling bottleneck in the architecture was the orchestration management that was implemented using AWS Step Functions. Our service performed multiple state transitions for every second of the stream, so we quickly reached account limits. Besides that, AWS Step Functions charges users per state transition." - Marcin Kolny, Senior SDE at Prime Video

"A wise man once told me: 'Nothing beats a function call.' I thought he was a dinosaur at that time… but there was wisdom in that quote, or maybe experience is turning me into a dinosaur too…

Jokes aside, I'm not saying that going monolithic is the ultimate answer once you reach a certain size or traffic level. But it's essential to dissect your application to understand where the bottlenecks are and make informed decisions. Don’t treat software architecture like a religion, behaving like Mandalorians, saying, "This is the way."

How Hard was it to Refactor?

Vendor lock-in can be a real pain, and it's a concern that many companies have when adopting serverless technology. Let's take a closer look at how the Prime Video team achieved the transition.

The following diagram shows the serverless architecture.

PrimeVideo stream monitor serverless architecure 

And this is their monolith architecture.

Prime video stream monitor monolith architecture


”Conceptually, the high-level architecture remained the same. We still have exactly the same components as we had in the initial design (media conversion, detectors, or orchestration). This allowed us to reuse a lot of code and quickly migrate to a new architecture.” - Marcin Kolny, Senior SDE at Prime Video

A well-structured application design is crucial, laying the foundation for scalability, maintainability, and efficiency. Investing time in design upfront saves resources in the long run by reducing costly refactoring and downtime, ultimately contributing to a project's future success. A great architecture is like a fine wine – it only gets better with time.

The Cost-Cutting Magic

By changing their architecture while staying on AWS, PrimeVideo managed to lower costs by an incredible 90%! But there are other ways to manage costs too.

For example, hybrid cloud solutions like Red Hat's OpenShift enable enterprises to benefit from both cloud and on-premise Kubernetes deployment, offering a powerful cost management tool (despite its challenges and complexities).

No matter the path, it's crucial for developers to be aware of the cost metrics of running an application. Make it part of your team's SLO, and watch your costs get under control.

The Only Constant is Change

So, next time you're faced with an architectural dilemma, remember PrimeVideo's story and don't be afraid to think outside the box. After all, change is the name of the game in software development. And who knows, maybe you'll find your own cost-cutting magic along the way!

Subscribe to my newsletter and receive articles straight to your inbox… for now. It's bound to evolve as usage grows, just like the fascinating world of software architecture.