Reverse engineering AWS Lambda

So I have been spending some time jamming my hands into AWS Lambda’s greasy internals, and I’d like to share all the wonderful details I’ve discovered.

why though?

I’ve use AWS Lambda quite extensively at work. And I wanted to get a better understanding of its inner working. What prompted this, you might ask?

Unofficial Native Go Runtime for Google Cloud Functions

There was an off handed comment by the author about the “Lambda API being a bit more complex.”

Well I aim to find out just how complex it is, with the end goal of writing a custom runtime, similar to the one above.

Probably in Python, just because it’s quick to prototype with.

Lets get started, shall we?

TL;DR

For the impatient of you, if you just want to see the results, feel free to look at the code here.

https://www.denialof.services/lambda/

A Decade of Dynamo: Powering the next wave of high-performance, internet-scale applications

Today marks the 10 year anniversary of Amazon’s Dynamo whitepaper, a milestone that made me reflect on how much innovation has occurred in the area of databases over the last decade and a good reminder on why taking a customer obsessed approach to solving hard problems can have lasting impact beyond your original expectations.

“Dynamo: Amazon’s Highly Available Key-value Store” received the ACM SIGOPS 2017 Hall of Fame Award

http://www.allthingsdistributed.com/2017/10/a-decade-of-dynamo.html

S3 Bucket Security: More Than ACLs and Policies

Many companies are suffering data breaches because attackers gain access to data in AWS S3 buckets. I don’t want to repeat all the news articles outlining all the S3 data breaches. A Google search will give many examples, and it seems like by the time I write this another one will be in the news. Instead, I’d like to jump to why these S3 bucket breaches are happening and how to securely store data in an S3 bucket.

https://www.secplicity.org/2017/10/13/s3-bucket-security-acls-policies/amp/

How Reuters Replaced WebSockets with Amazon Cognito and SQS

The advantages of a serverless architecture are, at this point, not really a matter of debate. The question for every application or component becomes, “How can I avoid having to manage servers?” Sometimes you come across a roadblock: Perhaps you need a GPU; it takes 60 seconds just to load a machine learning model; maybe your task takes longer than the 300 seconds Amazon gives you for a Lambda process and you can’t figure out how to chop it up. The excuses never end.

Perhaps you want to push events into a browser or app through a WebSocket to create something similar to a chat or email application. You could use Nginx and Redis to create topics and have applications subscribe to them via a push stream; however, that means managing some long-running processes and servers. You can fake it and pound your backend once a second, butBut Amazon SQS and Cognito offer an easier way. Each user session can be paired with a Cognito identity and an SQS queue meaning applications can use SQS long-polling to receive events in real-time. At Reuters, we use this in production to support messaging in event-driven web applications and have open-sourced the underlying Serverless stack.

https://serverless.com/blog/how-reuters-replaced-websockets-with-amazon-cognito-and-sqs/

Amazon DynamoDB Accelerator (DAX) – In-Memory Caching for Read-Intensive Workloads

I’m fairly sure that you already know about Amazon DynamoDB. As you probably know, it is a managed NoSQL database that scales to accommodate as much table space, read capacity, and write capacity as you need. With response times measured in single-digit milliseconds, our customers are using DynamoDB for many types of applications including adtech, IoT, gaming, media, online learning, travel, e-commerce, and finance. Some of these customers store more than 100 terabytes in a single DynamoDB table and make millions of read or write requests per second. The Amazon retail site relies on DynamoDB and uses it to withstand the traffic surges associated with brief, high-intensity events such as Black Friday, Cyber Monday, and Prime Day.

While DynamoDB’s ability to deliver fast, consistent performance benefits just about any application and workload, there’s always room to do even better. The business value of some workloads (gaming and adtech come to mind, but there are many others) is driven by low-latency, high-performance database reads. The ability to pull data from DynamoDB as quickly as possible leads to faster & more responsive games or ads that drive the highest click-through rates.

 https://aws.amazon.com/blogs/aws/amazon-dynamodb-accelerator-dax-in-memory-caching-for-read-intensive-workloads

Drawing lessons from the “ Bezos Way”

Amazon’s CEO annual letter to his shareholders is a must-read. Customer focus, decision-making or the importance of writing down important things… Here are my takeaways from Jeff’s latest.

Whatever we think of its founder and CEO, Amazon remains a remarkable example of great management. Since its 1994 start, the company enjoyed steady growth, relentlessly conquering new markets and sectors, coupled to exceptional resilience shown when the company weathered two market crashes (2000 and 2008). In addition, Bezos has demonstrated a consistent ability to convince his board and shareholders to let expansion take precedence over profits and dividends. (No one can complain: thousand dollars invested in Amazon’s 1997 IPO are now worth more than half a million, a 500x multiple).

This didn’t happen without damage. By some measures, Amazon isn’t an enviable place to work and the pressure it applies to its suppliers rivals the iron fist of Walmart’s purchasing department. All things considered, Amazon’s level of corporate toxicity remains reasonable compared to Uber, as an example.

Jeff Bezos is also able to project an ultra-long term vision with his space exploration project for which he personally invests about a billion dollars per year.

Closer to our concerns, he has boosted a respected but doomed news institution — The Washington Post — thanks to a combined investment in journalistic excellence and in technology, two areas left fallow by most publishers.

That is why I thought Bezos’ written addresses to his shareholders (here) are worth some exegesis.

Let start with last week’s letter. (Emphasis mine, and while quotes are lifted from the original documents, some paragraphs have been rearranged for clarity and brevity).

Bezos starts his 2016 missive with a question asked by staffers at all-hands meetings:

“Jeff, what does Day 2 look like? (…) [Bezos reply:] Day 2 is stasis. Followed by irrelevance. Followed by excruciating, painful decline. Followed by death. And that is why it is always Day 1.”

Then he enumerates the three obsessions that make Amazon what it is today:…

https://mondaynote.com/drawing-lessons-from-the-bezos-way-dd0e950ade68