Skillenza is back with another game-changing virtual hackathon for you. Seize this amazing opportunity to create projects on serverless architecture. For those of you who are not acquainted with it, serverless architectures are system designs that use third-party services to build and run applications.
As developers, this helps you to gain better scalability and flexibility without needing any administration to manage infrastructure. So you can build quicker and at a reduced cost as well.
https://skillenza.com/challenge/build-with-serverless-online-hackathon-aws
5. Using a serverless approach for A Cloud Guru, we were
able to get a fully interactive online social learning
platform to market in a fraction of the time that it would
have taken us in the past. We can now innovate quickly,
and add new features to the user interface continuously —
without having to touch so many layers of code for each
new feature.
Sam Kroonenburg, Co-Founder
IMAGINE TIMELINE!
6. https://read.acloud.guru/serverless-the-future-of-software-architecture-d4473ffed864
Using a serverless approach for A Cloud Guru, we were
able to get a fully interactive online social learning
platform to market in a fraction of the time that it would
have taken us in the past. We can now innovate quickly,
and add new features to the user interface continuously —
without having to touch so many layers of code for each
new feature.
Sam Kroonenburg, Co-Founder
HE WROTE THIS IN OCT 2015
7. Why Serverless!
● FOCUS on business logic
● Cloud provider MANAGES the infrastructure, availability, scalability, and
security
● Pay for what you CONSUME
8. One of the most important papers published for
Serverless Computing
Cloud Programming Simplified:
A Berkeley View on Serverless Computing (Feb, 2019)
https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.pdf
9. AWS Lambda is NOT THE ONLY
Serverless services.
IT IS RATHER A VERY MOST IMPORTANT ONE.
12. ● Enable X-ray, you need insights from very early stage
● Keep the function size as small as possible, for faster startup time
● Import only the required libraries (especially when working with NodeJS)
● Use minimum timeout or execute as fast as possible
● Use Lambda Layers if you have a lot of static dependencies
● Use Lambda Destinations for success/failure based orchestration
General practices while working with Lambda functions
13. ● If your function is calling multiple lambdas or some sort of wait/decision
tree, use Step Functions instead.
● Define IAM policies/role per function, least privilege principle
● Power-tune your functions and allocate proper resources
● Check the cold start time in your selected region
● Test and validate your requirement before going for Provisioned
Concurrency, it is very costly and you may not need it.
● Use a framework, Doesn't matter if it's Serverless, SAM or any other.
● Set proper concurrency limit for your functions to avoid any downward
impact.
General practices while working with Lambda functions
14. Keep the Lambda limits
in mind
- Some can be changed
- Others can not be changed
15. ● Concurrency
● Storage and Database Options
● Step Functions
● Observability
● Performance Optimization
● Cost
Let’s look at a few in detail...
16. Common observation as the application scale
increases
Timeouts
- API Gateway
- Lambda
- DB Connections
Throughput / Throttle
- Dependencies
- Lambda
- Other AWS services
Cost
- Higher execution
time, higher cost
17. Concurrency in Distributed Environment
● Autoscaling is core at the Serverless Infrastructure
● Different services scale differently
● Scaling directly impacts the performance and cost
● Service with lowest throughput becomes benchmark for entire pipeline
● Lambda can support Reserved and Provisioned Concurrency
● Reserved does not cost anything
● Provisioned costs huge
Spike/y (viral) access pattern is the new normal.
Take Skillenza as one of the examples. Their one program may receive more hits
compared to others. There might be a period where the overall load is consistent.
20. Database and Storage Service
● Huge number of options for storage and database
● Serverless compute, Serverless data storage
● NoSQL DynamoDB can scale to billions of transactions
● Aurora Serverless can manage many use cases. Use Data PAI instead of
connections.
● EFS can help process large files with low latency and overhead
● S3 can work as a highly durable centralize storage, also considered backbone
of AWS Cloud
● Athena can help extract the desired data without performing at ETL
operations
● RDS Proxy provides effective mechanism to use Relational Database with
Serverless application without managing the connection overhead.
22. Storage options
Service Storage Capacity
Lambda Storage /tmp directory 512 MB
S3 Object Storage
S3 Triggers to Invoke Lambda functions
Lifecycle rules for different storage tier
Can be access from Internet
Unlimited / Serverless
EFS File Storage
Low-latency storage
Lifecycle rules for Infrequent Access
storage tier
VPC-bound can not be accessed from
outside
Unlimited / Serverless
23. Orchestrate better with Step Functions
● One Lambda function will not be enough
● May need to run several functions in coordination to perform a task
● Loose coupling, loose integration
● Loose coupling, tight integration
● Ensure sure the desired workflow runs consistently
25. With Step Functions
Flow is orchestrated using Step Functions does same things.
(using Serverless Framework)
26. Observability (logging, debugging and tracing)
● Log complexity is proportional to the number of functions
● Different services add their own complexities
● Many services can not be tested in local environment
● Debugging and Tracing is not easy in the Cloud
● Use AWS CloudWatch, Lumigo.io for Logging
● Use AWS X-Ray, Lumigo.io, Dashbird.io for Tracing
● Use Thundra.io for Debugging, Security
30. Optimize your functions
● Start Fast, Finish Fast
● Functions run in micro-containers (Firecracker based)
● If functions are heavy in size or initialization, that would delay the
EXECUTION START time
● Lambda Layers can be pretty useful to move static dependencies
● Import only required libraries
● Different services has different latencies
● Adjust function timeouts accordingly
33. Analyse and Optimise
Re-use variables, decrease API calls to fetch configurations or other static detail, etc
34. Cost of running Serverless
● Every service is metered differently
● Pay close attention to what is important to your application
● Change in application usage pattern can skew the cost
● Something that work at the scale of 100s may not work at the scale of 1000s,
and will required re-architecture.
● Due to asynchronous nature, re-architecture may be a less disruptive
process.
35. Service Cost Meter
Service Type Count Cost
API Gateway REST Requests 1 Million $3.50
HTTP Request 1 Million $1
Lambda Request 1 Million $0.20
Duration every GB-second $0.0000166667
SQS Standard Queue 1 Million Request
Every SQS action = 1 Request
Data Transfer In/Out separate
$0.40
DynamoDB On-Demand Read 1 Million $0.285
On-Demand Write 1 Million
Data Storage separate
Data Transfer In/Out separate
$1.4231
The cost after the AWS Free Tier Limits https://aws.amazon.com/free
37. There is always a room for more...
● API Gateway - HTTP vs REST
● AppSync and GraphQL
● SQS Batch Size
● Kinesis Data Stream
● AWS IoT vs API Gateway
● API Gateway vs AppSync
● SQS, SNS, and EventBridge
38. Keep Experimenting
● In Serverless environment, everything is distributed and asynchronous
● Serverless landscape is evolving rapidly, lot of opportunity to refactor and
optimize
https://sls.dashbird.io/en/serverless-best-practices
39. Where to go from here
● AWS Well-Architected Framework for Serverless Applications
○ https://aws.amazon.com/blogs/aws/new-serverless-lens-in-aws-well-architected-tool/
● AWS Heroes
○ Yan Cui - https://theburningmonk.com/
○ Jeremy Daly - https://jeremydaly.com/
○ James Beswick (Serverless Developer Advocate, AWS)
■ https://aws.amazon.com/blogs/compute/author/jbeswick/
● AWS Blogs for Serverless
○ https://aws.amazon.com/blogs/compute/tag/serverless/
● Serverless Framework
○ https://serverless.com/
● Serverless Application Model
○ https://aws.amazon.com/serverless/sam/
40. Thank You! #GOSERVERLESS
Spare a few minutes and read this paper.
Cloud Programming Simplified:
A Berkeley View on Serverless Computing (Feb, 2019)
https://www2.eecs.berkeley.edu/Pubs/TechRpts/2019/EECS-2019-3.pdf
Above the Clouds: A Berkeley View of Cloud Computing (Feb, 2009)
https://www2.eecs.berkeley.edu/Pubs/TechRpts/2009/EECS-2009-28.pdf