Snap Inc. Reduces Median Latency of Sending Snaps by 20% Using Amazon DynamoDB
Camera company Snap Inc. (Snap) creates Snapchat, an app that offers its community around the world a fast and fun way to connect with close friends. Every day, over 290 million Snapchatters on average use the app, sending billions of pictures and video messages called “Snaps.” Before Snapchat could reach this scale, however, it needed to modernize its legacy monolithic infrastructure. Snap was born in the cloud, and as part of its evolution to provide a compelling experience for hundreds of millions of users, Snap made the move to a service-oriented, regionalized, cost-efficient, durable architecture by using Amazon Web Services (AWS).
Snap modernized Snapchat’s architecture using microservices built around services like Amazon DynamoDB, a key-value and document database that delivers single-digit millisecond performance at any scale. “As the number of Snapchatters grew to hundreds of millions, we did some technical diligence and found that Amazon DynamoDB was the right technology choice for us,” says Saral Jain, director of engineering and the head of infrastructure at Snap. “We wanted to move to an operationally reliable and cost-efficient solution that offered a low-latency experience for our customers.”
The company used Amazon DynamoDB across several use cases, including its mission-critical messaging service, to seamlessly scale as needed, reduce latency, and save on infrastructure costs. This modernization also enabled Snap to build the regionalized database structure it needed to provide a fast experience to users around the world. “Migrating to Amazon DynamoDB has helped Snap optimize annual infrastructure costs significantly—in addition to providing low latency and operational reliability for core use cases like messaging and our friend graph,” says Jain.
Migrating to Amazon DynamoDB has helped Snap optimize annual infrastructure costs significantly—in addition to providing low latency and operational reliability for core use cases like messaging and our friend graph."
Director of Engineering and Head of Infrastructure, Snap Inc.
Finding an Agile Solution with Global Potential
First developed in 2011, Snapchat was built as part of a monolithic architecture where the majority of the Snapchat features were served from a single service application. Apart from limiting operational agility, this architecture made it more likely that certain problems would have a large blast radius and cause a major impact, such as system-wide service disruptions. As Snap grew, it needed to deconstruct this monolithic architecture and replace it with a modern microservices solution that would also be capable of regionalizing the company’s data layer—all to support the company’s vision for a system that supports globally distributed users with low latency.
Snap was attracted to the flexible pricing options offered by Amazon DynamoDB, including provisioned capacity mode, which makes it easier for customers to manage the capacity required for their applications and includes Amazon DynamoDB auto scaling, which adjusts capacity automatically and efficiently to help reduce costs. “Amazon DynamoDB offers consistent performance with provisioned capacity, an important feature that we didn’t have before,” says Umit Akkus, software engineer for Snap. Using provisioned capacity mode and Amazon DynamoDB auto scaling enables Snap to pay in advance for discounted capacity and helps the company maintain reliable throughput while automatically scaling up or down as needed to optimize costs.
The built-in security and natively supported backup and restore features also attracted Snap to Amazon DynamoDB. Also appealing was Amazon DynamoDB point-in-time recovery, which enables customers to back up table data continuously and automatically with per-second granularity so that they can restore to any given second in the preceding 35 days.
Managing Seasonal Usage Spikes and Optimizing Costs Using Amazon DynamoDB
Snap conducted the majority of the migration process for its Snapchat databases in 2018. Rather than viewing the migration as a challenge, the team saw it as an opportunity. “Migrating to Amazon DynamoDB gave us the chance to rearchitect the data—to rethink how we want to structure the entities and the relationships between them and how we isolate different kinds of entities,” says Jain. Once the monolithic application had been refactored into a microservices architecture, the migration team carried out a live migration to avoid disrupting service for Snapchat users, carefully selecting the order in which datasets would move to the cloud.
As a result, Snap has seen better performance after migrating to Amazon DynamoDB. “Through the recent rewrite of our communications solution, we reduced the median latency of sending Snaps by over 20 percent, which supports our efforts to be one of the fastest ways to communicate,” says Jain. Snap is also now better positioned to manage usage spikes—including those that accompany holidays such as New Year’s Eve. “Across several use cases, we can use Amazon DynamoDB to handle more than 10 million queries per second during peak hours—and with high availability and operational reliability,” says Jain. “Because of the operational maturity and muscle of AWS, we are able to make sure that the architecture is optimized and ready to tackle these events.” Snapchat has a cyclical usage pattern, in which demands fluctuate throughout the day, so automatically scaling to meet peak and low traffic resulted in optimized costs for the company. Other services using Amazon DynamoDB include creative tools like the sticker packs, Bitmoji, the friend graph, and certain custom stories.
Focusing on Relationships to Build a Better Network
As Snap continues to grow with more users around the world, it intends to use key Amazon DynamoDB features, such as Amazon DynamoDB global tables, which enable replication of Amazon DynamoDB tables automatically across Snap’s specific choices of AWS Regions and deliver fast, local, read-and-write performance for this massively scaled global application. “As we think about running our infrastructure, we want to use AWS to solve some of the undifferentiated, harder problems so that we can focus on how to best build a delightful experience for Snapchat users,” says Jain. “Replicating data across different regions is a pretty hard problem, and we can use Amazon DynamoDB global tables to do that with ease.”
Going forward, Snap sees more opportunities to innovate on AWS. “The capabilities Amazon DynamoDB offers and the continued innovation within it give us confidence that we can continue relying on it and innovating on top of it,” says Jain. As friends around the world continue to communicate and build relationships on Snapchat, the team behind the scenes will continue to build on AWS and strengthen the technology at the heart of those relationships.
About Snap Inc.
Founded in 2011, Snap Inc. is a social media company that empowers people to live in the moment. Its flagship app, Snapchat, has over 270 million daily global users.
Benefits of AWS
- Reduced median latency of sending Snaps by over 20%
- Scales up to handle over 10 million queries per second on high-traffic days
- Enables consistent, low-latency performance for users around the world
- Optimized annual infrastructure costs significantly
AWS Services Used
Amazon DynamoDB is a key-value and document database that delivers single-digit millisecond performance at any scale.
Companies of all sizes across all industries are transforming their businesses every day using AWS. Contact our experts and start your own AWS Cloud journey today.