Speaker: 西谷 圭介, AWS Japan
- The only tunable parameter is MEMORY, but, in fact, it affects all computing resources ex. CPU usage
- Reduce package size
- using client library
- ex) Uglify.js
- using client library
- Do NOT use VPCs
- 10-30 additional latencies for attachng ENIs
- 1 lambda function : 1 responsibility
- Separate handler code and busines logics
- keep your business logic testabile
- Initialize in global scope
- resources allocated in global scope is REUSED by another execution (if it's warm-start context)
- Do not write orchestration code in your function
- easy to cause timeout
- use AWS Step Functions instead
- In error handling...
- Set timeouts for external services
- ex) HTTP, Redis, DynamoDB
- if lambda function timeouts before external service calls timeouts, no logs output
- Retry invokations
- use exponential backoff with jitter
- Set timeouts for external services
- Do not use pre-installed SDKs
- AWS periodically updates them
- it may affect your code
- AWS periodically updates them
- Use asyncronous invokation instead of syncronous invokation
- Keep idempotency for yourself
- lambda may executes multiple times
- Do not hard-code
- sepalate logics and configulations
- easy to switch environments
- reduce security risks
- store configuration in managed services
- System Manager - Paramteter Store (Free of charge)
- Secret Manager (charges)
- sepalate logics and configulations
- Do not use RDB
- hundreds & thousands of concurrent executions of Lambda Functions may exceeds max connection limits of RDB
- VPC coldstart is unavoidable
- Use scalable database ex. Dynamo DB instead
- connections scaleout
- no VPC coldstart
- throughputs also scaleout
- If you have to use RDB ...
- control max concurrecy limit
- Do not use fixed IP addresses
- VPC coldstart
- ENI becomes single point of failure
- Allow minimum necessary permitions as possible
- If you test lambda function code ...
- run unittext on your local machine
- run integration test on actural managed services
- maintaining mocks and stabs costs high
- run test on pipeline