Slide 1

Slide 1 text

Is it wrong to use a web framework with Lambda? Koki Miura(@k_miura_io)

Slide 2

Slide 2 text

INTRODUCTION • Koki Miura • Backend Engineer @Acall inc • Staff @JAWS UG Nagoya & Kobe • Favorite AWS Services:AWS IoT, Lambda, ECS

Slide 3

Slide 3 text

Can we use Lambda with web framework? Setting “ANY {proxy+}” in the API Gateway routing configuration enables routing of applications running within a Lambda function.

Slide 4

Slide 4 text

Lambda Deploy Pattern ZIP file Lambda Layer Container Web Adapter

Slide 5

Slide 5 text

ZIP File • Zipped function code with dependencies • Merit: Simple deploy • Demerit: Maximum size is 250MB when unzipped

Slide 6

Slide 6 text

Lambda Layer • Deploy dependencies as split layer • Merit: Share dependencies another application • Demerit: Maximum size is 250MB when unzipped with functions

Slide 7

Slide 7 text

Container • Deploy container image which based Lambda runtime • Merit: Maximum size is 10GB image • Demerit: Still need to set up the inputs and outputs to match the Lambda interface

Slide 8

Slide 8 text

Web Adapter • Rust based tool to run web applications on Lambda • Merit: Unnecessary arrange the inputs and outputs to match the Lambda interface • Demerit: Can be set up in either Layer or Container, but Layer may be more time-consuming. https://github.com/awslabs/aws-lambda-web-adapter

Slide 9

Slide 9 text

PERFORMANCE COMPARISON

Slide 10

Slide 10 text

Rule • There are 5 scenarios by deploy pattern • Lab1: Web framework app which deploy zip file • Lab2: Web framework app which uses layer of dependencies • Lab3: Web framework app which deploy container image • Lab4: Web framework app which uses web adapter • Lab5: Pure Lambda function app same web framework • All scenario’s uses Node.js runtime • Use Locust and perform a 5-minute load test assuming 100 people accessing the site. • Source code of these scenarios: https://github.com/Miura55/pankration2024_lambda_demos

Slide 11

Slide 11 text

Result Type Name Requests Fails Average (ms) Min (ms) Max (ms) Average size (bytes) RPS Failures/s GET /Prod/users 24029 915 43.35 21 1000 70.63 80.09 3.05 Lab1 (ZIP) Type Name Requests Fails Average (ms) Min (ms) Max (ms) Average size (bytes) RPS Failures/s GET /Prod/users 24049 1353 43.52 20 1094 69.97 80.16 4.51 Lab2 (Layer)

Slide 12

Slide 12 text

Type Name Requests Fails Average (ms) Min (ms) Max (ms) Average size (bytes) RPS Failures/s GET /Prod/users 24053 1497 42.3 20 769 69.76 80.18 4.99 Lab4 (Web Adapter) Type Name Requests Fails Average (ms) Min (ms) Max (ms) Average size (bytes) RPS Failures/s GET /Prod/users 24066 1200 41.87 21 1256 70.2 80.22 4 Lab3 (Cotainer) Type Name Requests Fails Average (ms) Min (ms) Max (ms) Average size (bytes) RPS Failures/s GET /Prod/users 24182 1065 37.5 19 1093 70.41 80.61 3.55 Lab5 (Pure Lambda)

Slide 13

Slide 13 text

From Result • Locust was being requested concurrently, and in both scenarios, the request was failing with an error when the Lambda concurrency limit was applied in the latter half of the request • Slow initial requests tended to result in failures in requests in the second half of the request Container Layer Zip Pure Lambda Faster Later Request Time

Slide 14

Slide 14 text

Conclusion • Container based application can execute computing with web adapter in Lambda • Container runtime takes time to cold-start longer • If you replace web framework application to Lambda, recommend to split function to pure Lambda

Slide 15

Slide 15 text

END