In recent years, microservices have gained popularity as an architectural pattern that allows organizations to build and deploy applications faster and more efficiently. However, as Amazon discovered, microservices aren't always the best choice.
In a recent post, the team that works on Amazon's Prime Video explained their approach to ensuring customers receive high-quality content. They use a tool to monitor every stream viewed by customers and identify quality issues.
Initially, the tool was intended to run on a small scale, but the team noticed that monitoring more streams caused the service to become less responsive. Therefore, they decided to revise the architecture.
The initial architecture consisted of several serverless components orchestrated by AWS Step Functions. The components were responsible for performing various tasks such as processing video, analyzing logs, and sending notifications.
The team chose to build the initial solution with serverless components because it enabled them to develop and scale each component quickly. However, they soon discovered that using some components caused performance issues, accounting for 5% of the expected load.
The following diagram shows the serverless architecture of the service.
After analyzing the performance issues, the team concluded that the distributed approach didn't bring many benefits. As a result, they packed all the components into a single process, moving expensive operations between components into a single process to keep the data more trans within process memory.
By moving to a monolithic architecture, the team reduced the service's response time to a monolithic level and reduced the infrastructure cost by over 90%. Moreover, the service scaled better and had improved reliability.
The following diagram shows the architecture of the system after migrating to the monolith.
While microservices can offer several advantages, they're not always the right choice. Sometimes, monolithic architecture can be a better fit, depending on the project's requirements. Amazon's Prime Video quality monitoring service is an excellent example of how moving from microservices to a monolith improved performance, scalability, and reliability.
In summary, organizations should evaluate their project requirements and choose an architecture that best suits their needs, rather than following industry trends blindly.