Alex Xu Profile picture
Mar 31 โ€ข 8 tweets โ€ข 3 min read
๐’๐ž๐ซ๐ฏ๐ž๐ซ๐ฅ๐ž๐ฌ๐ฌ is one of the hottest topics in cloud services. How does AWS ๐‹๐š๐ฆ๐›๐๐š work behind the scenes?

Lambda is a ๐ฌ๐ž๐ซ๐ฏ๐ž๐ซ๐ฅ๐ž๐ฌ๐ฌ computing service provided by Amazon Web Services (AWS), which runs functions in response to events. Image
๐…๐ข๐ซ๐ž๐œ๐ซ๐š๐œ๐ค๐ž๐ซ ๐Œ๐ข๐œ๐ซ๐จ๐•๐Œ
Firecracker is the engine powering all of the Lambda functions [1]. It is a virtualization technology developed at Amazon and written in Rust.

The diagram below illustrates the isolation model for AWS Lambda Workers.
Lambda functions run within a sandbox, which provides a minimal Linux userland, some common libraries and utilities. It creates the Execution environment (worker) on EC2 instances.

How are lambdas initiated and invoked? There are two ways. Image
๐’๐ฒ๐ง๐œ๐ก๐ซ๐จ๐ง๐จ๐ฎ๐ฌ ๐ž๐ฑ๐ž๐œ๐ฎ๐ญ๐ข๐จ๐ง
Step1: "The Worker Manager communicates with a Placement Service which is responsible to place a workload on a location for the given host (itโ€™s provisioning the sandbox) and returns that to the Worker Manager" [2]. Image
Step 2: "The Worker Manager can then call ๐˜๐˜ฏ๐˜ช๐˜ต to initialize the function for execution by downloading the Lambda package from S3 and setting up the Lambda runtime" [2]

Step 3: The Frontend Worker is now able to call ๐˜๐˜ฏ๐˜ท๐˜ฐ๐˜ฌ๐˜ฆ [2]. Image
๐€๐ฌ๐ฒ๐ง๐œ๐ก๐ซ๐จ๐ง๐จ๐ฎ๐ฌ ๐ž๐ฑ๐ž๐œ๐ฎ๐ญ๐ข๐จ๐ง
Step 1: The Application Load Balancer forwards the invocation to an available Frontend which places the event onto an internal queue(SQS). Image
Step 2: There is "a set of pollers assigned to this internal queue which are responsible for polling it and moving the event onto a Frontend synchronously. After itโ€™s been placed onto the Frontend it follows the synchronous invocation call pattern which we covered earlier" [2]. Image
Question: Can you think of any use cases for AWS Lambda?

Sources:
[1] AWS Lambda whitepaper: docs.aws.amazon.com/whitepapers/laโ€ฆ
[2] Behind the scenes, Lambda: bschaatsbergen.com/behind-the-sceโ€ฆ
Image source: [1] [2]

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Alex Xu

Alex Xu Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @alexxubyte

Mar 30
HTTP 1.0 -> HTTP 1.1 -> HTTP 2.0 -> HTTP 3.0 (QUIC).

What problem does each generation of HTTP solve?

The diagram below illustrates the key features.

๐Ÿ”นHTTP 1.0 was finalized and fully documented in 1996. Every request to the same server requires a separate TCP connection. Image
๐Ÿ”นHTTP 1.1 was published in 1997. A TCP connection can be left open for reuse (persistent connection), but it doesnโ€™t solve the HOL (head-of-line) blocking issue. Image
HOL blocking - when the number of allowed parallel requests in the browser is used up, subsequent requests need to wait for the former ones to complete.
Read 8 tweets
Mar 29
How to scale a website to support millions of users? We will explain this step-by-step.

The diagram below illustrates the evolution of a simplified eCommerce website. It goes from a monolithic design on one single server, to a service-oriented/microservice architecture.
Suppose we have two services: inventory service (handles product descriptions and inventory management) and user service (handles user information, registration, login, etc.).
Step 1 - With the growth of the user base, one single application server cannot handle the traffic anymore. We put the application server and the database server into two separate servers.
Read 9 tweets
Mar 28
Some ๐ƒ๐ž๐ฏ๐Ž๐ฉ๐ฌ books I find enlightening:

๐Ÿ”นAccelerate - presents both the findings and the science behind measuring software delivery performance.

๐Ÿ”นContinuous Delivery - introduces automated architecture management and data migration.
๐Ÿ”นSite Reliability Engineering - famous Google SRE book. It explains the whole life cycle of Googleโ€™s development, deployment, and monitoring, and how to manage the worldโ€™s biggest software systems.

๐Ÿ”นEffective DevOps - provides effective ways to improve team coordination.
๐Ÿ”นThe Phoenix Project - a classic novel about effectiveness and communications. IT work is like manufacturing plant work, and a system must be established to streamline the workflow. Very interesting read!
Read 4 tweets
Mar 23
Why is Kafka fast?

Kafka achieves low latency message delivery through Sequential I/O and Zero Copy Principle. The same techniques are commonly used in many other messaging/streaming platforms.
The diagram below illustrates how the data is transmitted between producer and consumer, and what zero-copy means.

๐Ÿ”นStep 1.1 - 1.3: Producer writes data to the disk

๐Ÿ”นStep 2: Consumer reads data without zero-copy

2.1: The data is loaded from disk to OS cache
2.2 The data is copied from OS cache to Kafka application
2.3 Kafka application copies the data into the socket buffer
2.4 The data is copied from socket buffer to network card
2.5 The network card sends data out to the consumer
Read 6 tweets
Mar 10
One picture is worth more than a thousand words. In this post, we will take a look at what happens when Alice sends an email to Bob.1/4 Image
1. Alice logs in to her Outlook client, composes an email, and presses โ€œsendโ€. The email is sent to the Outlook mail server. The communication protocol between the Outlook client and mail server is SMTP.2/4 Image
2. Outlook mail server queries the DNS (not shown in the diagram) to find the address of the recipientโ€™s SMTP server. In this case, it is Gmailโ€™s SMTP server. Next, it transfers the email to the Gmail mail server. The communication protocol between the mail servers is SMTP.3/4 Image
Read 4 tweets
Mar 9
Caching is awesome but it doesnโ€™t come without a cost, just like many things in life.

One of the issues is cache miss attack. Correct me if this is not the right term. It refers to the scenario where data to fetch doesn't exist in the database and the data isnโ€™t cached either. Image
So every request hits the database eventually, defeating the purpose of using a cache. If a malicious user initiates lots of queries with such keys, the database can easily be overloaded.

The diagram below illustrates the process.
Two approaches are commonly used to solve this problem:

๐Ÿ”นCache keys with null value. Set a short TTL (Time to Live) for keys with null value. Image
Read 5 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(