AWS Storage Blog
How Fetch reduced latency on image uploads using Amazon S3 Express One Zone
Fetch provides a convenient and rewarding platform for consumers to earn points and redeem them for various goods and services, making it an attractive option for those looking to maximize the value of their everyday purchases. Fetch’s users use a simple interface to upload their receipts for scanning and earn points for every receipt they upload.
Fetch reduced latency by 91% for part of its most critical user flow, uploading a receipt, using the Amazon S3 Express One Zone storage class. S3 Express One Zone is a high-performance, single-Availability Zone (AZ) storage class purpose-built to deliver consistent single-digit millisecond first byte latency for latency-sensitive applications. Making sure that a user can complete the receipt upload flow effortlessly and quickly is a critical metric for Fetch to make sure its users have a positive experience and that user retention remains high.
In this post, we explore how Fetch addressed latency challenges in a component of one its most critical workloads, receipt image-processing, using S3 Express One Zone. We begin by examining the challenges Fetch faced in their prior architecture, which consisted of Amazon Simple Storage Service (S3) and custom machine learning (ML) models hosted on Amazon SageMaker. Then, we discuss how the introduction of S3 Express One Zone allowed Fetch to achieve a 91% reduction in latency for data ingestion from Amazon Elastic Container Service (ECS).
Opportunity
In 2023, Fetch embarked on a major re-architecture of its receipt image-processing application. A key goal was to move the uploading of images from the mobile app to their backend application to improve performance and reduce failures. As part of this re-architecture, shown in the following diagram, they changed the upload of the receipt image to be synchronous, instead of asynchronous, to make sure the images are uploaded if the request succeeds.
During the rollout of the new architecture in production, Fetch noticed that uploads to S3 Standard from Amazon ECS were slower than the image processing that was happening in parallel via SageMaker. This caused an increase in the overall time it took users to receive a response from ECS after uploading a receipt, with ECS waiting for the upload to S3 to complete after image processing had already completed. Therefore, the Fetch team was looking for ways to reduce the latency of uploads to Amazon S3 to reduce the overall time taken.
Solution overview
When AWS announced S3 Express One Zone at re:Invent 2023, Fetch realized this new storage class may be exactly what they needed given its consistent single-digit millisecond latency. In the application architecture, the receipt image uploads to S3 and SageMaker processing of the images happen in parallel. Therefore, S3 Express One Zone’s single-digit millisecond latency would reduce the overall time taken from an end user perspective, as they would receive a response from ECS more quickly given that it could immediately respond after SageMaker processing had completed without having to wait for the uploads to catch up. Fetch changed their architecture so the receipt images would be directly uploaded to an S3 directory bucket, the new bucket type that allows objects stored in the S3 Express One Zone storage class. Since the APIs are the same across both S3 bucket types, general purpose and directory, there were minimal code changes and Fetch was able to quickly implement, test, and deploy the changes to production.
The following image outlines the updated workflow of the receipt image-processing application:
1. Users first upload receipt image(s) to Amazon ECS through an AWS Global Accelerator endpoint and an Application Load Balancer (ALB).
2. Amazon ECS performs the following two actions in parallel:
2a. ECS stores the uploaded images in S3 Express One Zone. Previously, ECS stored the uploaded images directly to S3 Standard.
2b. ECS invokes a custom model, hosted in SageMaker, passing each image uploaded to the model to understand the items on the receipt.
3. Once the processing is complete and a success is returned to the user, the images are moved from S3 Express One Zone to S3 Standard.
Outcome
With the rollout of this change, Fetch’s end-to-end latency when uploading a receipt image from ECS to S3 went from an average of 132 ms when uploading to S3 Standard down to an average of 11.4 ms when uploading to S3 Express One Zone, a 91% reduction. After introducing this change, less than 0.002% of images took longer to upload to S3 Express One Zone than it took SageMaker to process the image, which was a significant improvement. The following image shows the reduction in latency for receipt image uploads after S3 Express One Zone was introduced in early January 2024.
This latency reduction helps make sure Fetch delivers a frictionless user experience while also being able to quickly process these receipt images to get rewards to their users. To date, Fetch users have uploaded over 280 million images using S3 Express One Zone.
Conclusion
In this post, we talked about how Fetch incorporated Amazon S3 Express One Zone into its receipt image-processing application to reduce latency. The introduction of S3 Express One Zone reduced latency by 91%, removing a bottleneck in the image storage and processing workflow and reducing the time it takes end users to receive a response after uploading a receipt.
Given Fetch’s nationwide user base, the company is now exploring migrating to a multi-Region architecture. The objective is to position the workload in closer proximity to its end users, thus further reducing latency by making sure that Fetch’s workloads are running as close to the users as possible, regardless of their location across the United States. Fetch continually works to improve their world class app experience to make sure it remains highly ranked and receives 5-star reviews.
Thank you for reading this post. If you are interested in learning more about S3 Express One Zone, visit the S3 User Guide. And if you have any questions or comments, leave them in the comments section.