After a number of public betas, we launched Amazon Easy Queue Service (Amazon SQS) in 2006. Practically 20 years later, this absolutely managed service continues to be a elementary constructing block for microservices, distributed methods, and serverless purposes, processing over 100 million messages per second at peak occasions.
As a result of there’s all the time a greater approach, we proceed to search for methods to enhance efficiency, safety, inside effectivity, and so forth. After we do discover a potential strategy to do one thing higher, we’re cautious to protect current habits, and infrequently run new and outdated methods in parallel to permit us to match outcomes.
At this time I want to let you know how we just lately made enhancements to Amazon SQS to cut back latency, improve fleet capability, mitigate an approaching scalability cliff, and scale back energy consumption.
Enhancing SQS
Like many AWS providers, Amazon SQS is carried out utilizing a group of inside microservices. Let’s deal with two of them right now:
Buyer Entrance-Finish – The client-facing front-end accepts, authenticates, and authorizes API calls resembling CreateQueue and SendMessage. It then routes every request to the storage back-end.
Storage Again-Finish -This inside microservice is liable for persisting messages despatched to straightforward (non-FIFO) queues. Utilizing a cell-based mannequin, every cluster within the cell comprises a number of hosts, every buyer queue is assigned to a number of clusters, and every cluster is liable for a mess of queues:

Connections – Previous and New
The unique implementation used a connection per request between these two providers. Every front-end had to connect with many hosts, which mandated the usage of a connection pool, and likewise risked reaching an final, hard-wired restrict on the variety of open connections. Whereas it’s typically attainable to easily throw {hardware} at issues like this and scale out, that’s not all the time one of the best ways. It merely strikes the second of fact (the “scalability cliff”) into the long run and doesn’t make environment friendly use of assets.
After fastidiously contemplating a number of long-term options, the Amazon SQS workforce invented a brand new, proprietary binary framing protocol between the shopper front-end and storage back-end. The protocol multiplexes a number of requests and responses throughout a single connection, utilizing 128-bit IDs and checksumming to stop crosstalk. Server-side encryption offers an extra layer of safety in opposition to unauthorized entry to queue information.
It Works!
The brand new protocol was put into manufacturing earlier this 12 months and has processed 744.9 trillion requests as I write this. The scalability cliff has been eradicated and we’re already in search of methods to place this new protocol to work in different methods.
Efficiency-wise, the brand new protocol has lowered dataplane latency by 11% on common, and by 17.4% on the P90 mark. Along with making SQS itself extra performant, this variation advantages providers that construct on SQS as properly. For instance, messages despatched by Amazon Easy Notification Service (Amazon SNS) now spend 10% much less time “inside” earlier than being delivered. Lastly, because of the protocol change, the present fleet of SQS hosts (a mixture of X86 and Graviton-powered situations) can now deal with 17.8% extra requests than earlier than.
Extra to Come
I hope that you’ve loved this little peek contained in the implementation of Amazon SQS. Let me know within the feedback, and I’ll see if I can discover some extra tales to share.
— Jeff;

