¿Qué es eso del desarrollo sin servidores? ¿Qué lenguajes puedo utilizar? ¿Cómo hago cosas como autenticación, o guardar en base de datos, o enviar notificaciones? ¿Esto escala? A todas estas preguntas, y a alguna más, intentaré dar respuesta en esta sesión, donde haré una pequeña demo de montar una app muy sencilla y desplegarla en la nube sin preocuparnos de gestionar infraestructura. Charla realizada por primera vez para AlcarriaConf 2021
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
Primeros pasos en desarrollo serverless
1. Primeros pasos en desarrollo
serverless
Javier Ramírez
Developer Advocate - Amazon Web Services
@supercoco9 ramirez
2. We are witnessing a paradigm shift
Experiment,
innovate
more often
Release
features
faster
Build better
products
Focus on
business
logic
Decouple
software
systems
Win
customers
Win
customers
75% of organizations use or plan to use serverless
technologies within the next two years.1
* 451 Research, The Journey to Serverless-First: Enterprise Stories
https://aws.amazon.com/resources/analyst-reports/451-serverless-first-enterprises-on-aws/
3. Sumo Logic’s analysis of its AWS customers’ activities found a modest increase in
those running Lambdas, going from 36% in 2019 to 39% in 2020. In early 2020,
Datadog reported that more than 40% of its AWS customers had adopted Lambda,
with that figure almost doubling among AWS customers that also used containers.
https://thenewstack.io/adoption-of-aws-lambda-serverless-stalls/
https://www.sumologic.com/brief/continuous-intelligence-report/
4. Development transformation at Amazon (and everywhere else)
1994-2001 2002+
Monolithic architecture +
hierarchical organization
Decoupled services +
Two-pizza teams
6. Amazon S3 @ re:Invent 2018:
In 2020 S3 stored over 100 trillion (1014,
or 100,000,000,000,000) objects, and
regularly peaks at tens of millions of
requests per second.
8. Computing evolution – A paradigm shift
LEVEL
OF
ABSTRACTION
FOCUS ON BUSINESS LOGIC
PHYSICAL MACHINES
Requires “guess” planning
Lives for years on-premises
Heavy investments (capex)
Low innovation factor
Deploy in months
9. Computing evolution – A paradigm shift
LEVEL
OF
ABSTRACTION
FOCUS ON BUSINESS LOGIC
VIRTUAL MACHINES
Hardware independence
Faster provisioning speed (minutes/hours)
Trade capex for opex
More scale
Elastic resources
Faster speed and agility
Reduced maintenance
10. Computing evolution – A paradigm shift
LEVEL
OF
ABSTRACTION
FOCUS ON BUSINESS LOGIC
CONTAINERIZATION
Platform independence
Consistent runtime environment
Higher resource utilization
Easier and faster deployments
Isolation and sandboxing
Start speed (deploy in seconds)
11. No server is easier to manage than
"no server.”
Werner Vogels—Amazon CTO
12. Computing evolution – A paradigm shift
AWS Lambda
AWS Fargate
LEVEL
OF
ABSTRACTION
FOCUS ON BUSINESS LOGIC
Continuous scaling
Fault tolerance built-in
Pay for value
Zero maintenance
SERVERLESS
13. AWS operational responsibility models
On-Premises Cloud
Less More
Compute Virtual Machine
EC2 Elastic Beanstalk AWS Lambda
Fargate
Databases MySQL MySQL on EC2
RDS MySQL RDS Aurora Aurora Serverless DynamoDB
Storage Storage
S3
Messaging ESBs
Amazon MQ Kinesis SQS / SNS
Analytics
Hadoop Hadoop on EC2 EMR Elasticsearch Service Athena
14. Serverless means …
No servers to provision
or manage
Scales with usage
Never pay for idle Availability and fault
tolerance built in
18. Introduction to AWS Lambda
• Function-as-a-Service
• Run code without provisioning or managing servers
• Pay only for the compute time you consume
• Automatically runs your code with high availability
• Scale with usage
19. Lambda handles
• Load balancing
• Auto scaling
• Handling failures
• Security isolation
• OS management
• Managing utilization
(and many other things) for you
20. Comparison of operational responsibility
AWS Lambda
Serverless functions
AWS Fargate
Serverless containers
ECS/EKS
Container-management as a service
EC2
Infrastructure-as-a-Service
More opinionated
Less opinionated
AWS manages Customer manages
• Data source integrations
• Physical hardware, software, networking,
and facilities
• Provisioning
• Application code
• Container orchestration, provisioning
• Cluster scaling
• Physical hardware, host OS/kernel,
networking, and facilities
• Application code
• Data source integrations
• Security config and updates, network config,
management tasks
• Container orchestration control plane
• Physical hardware software, networking,
and facilities
• Application code
• Data source integrations
• Work clusters
• Security config and updates, network config,
firewall, management tasks
• Physical hardware software,
networking, and facilities
• Application code
• Data source integrations
• Scaling
• Security config and updates, network config,
management tasks
• Provisioning,managing scaling and
patching of servers
21. Customer uses cases: Lambda at scale
processes 4,000 requests
per second
processes half a trillion
validations of stock trades daily
triggers 1.2 billion Lambda
requests each month
Scaled up to 20,000
concurrent Lambda executions
in testing
25. Serverless Applications
Event source Function
Node.js
Python
Java
C#
Go
Ruby
PowerShell
Runtime API
Changes in
data state
Requests to
endpoints
Changes in
Resource state
27. Serverless Applications
Event source Services
Changes in
data state
Requests to
endpoints
Changes in
Resource state
Function
Node.js
Python
Java
C#
Go
Ruby
PowerShell
Runtime API
29. Dead-Letter Queue
• Asynchronous Lambda invocations are retried two more
times (3 times total)
• Lambda can forward payloads that were not processed
to a dead-letter queue (IF configured!)
• A mechanism to handle exceptions and failures
gracefully
30. Monitoring and debugging Lambda functions
• AWS Lambda console includes a dashboard for functions
• Lists all Lambda functions
• Easy editing of resources, event sources and other settings
• At-a-glance metrics
• Metrics automatically reported to Amazon CloudWatch for each Lambda
function
• Requests
• Errors
• Latency
• Throttles
31. AWS X-Ray
Profile and troubleshoot
serverless applications:
• Lambda instruments
incoming requests for all
supported languages and can
capture calls made in code
• API Gateway inserts a tracing
header into HTTP calls as
well as reports data back to
X-Ray itself
var AWSXRay = require(‘aws-xray-sdk-core‘);
var AWS = AWSXRay.captureAWS(require(‘aws-sdk’));
S3Client = AWS.S3();
32. Anatomy of a Lambda Function
Handler() function
Function to be executed upon
invocation
Event object
Data sent during Lambda
function Invocation
Context object
Methods available to interact
with runtime information
(request ID, log group, more)
import json
def lambda_handler(event, context):
# TODO implement
return {
'statusCode': 200,
'body': json.dumps('Hello World!')
}
33. Lambda Layers
Lets functions easily share code: Upload layer
once, reference within any function
Promote separation of responsibilities, lets
developers iterate faster on writing business logic
Built in support for secure sharing by ecosystem
34. Lambda Layers: Uses cases
• Custom code, that is used by more than one function
• Libraries, modules, frameworks to simplify the
implementation of your business logic
• Security/monitoring service
• Shared code that does not change frequently
• Bring your own Runtime
• C++
• Rust
• PHP
35. Fine-grained Pricing
Buy compute time in 1ms
increments
Low request charge
No hourly, daily, or monthly
minimums
No per-device fees
Never pay for idle
Free Tier
1M requests and 400,000 GBs of compute.
Every month, every customer.
37. AWS Compute Offerings
Service
I want to
configure
servers, storage,
networking, and
my OS
I want to run
servers,
configure
applications, and
control scaling
Run my code
when it’s
needed
How do I
choose?
Amazon EC2 Amazon ECS AWS Lambda
AWS Fargate
I want to run my
containers
38. Serverless compute engine
for containers
Long-running
Bring existing code
Fully-managed orchestration
AWS Fargate
The two Serverless compute options
Serverless event-driven
code execution
Short-lived
All language runtimes
Data source integrations
AWS Lambda
41. Orchestration for serverless apps
“I want to sequence functions”
“I want to select functions based on data”
“I want to run functions in parallel”
“I want to retry functions”
“I want to try/catch/finally”
“I want to run code for hours”
AWS Step Functions
42. AWS Step Functions
Visualize in the
Console
Define in JSON Monitor
Executions
Easily coordinate multiple Lambda functions using visual workflows
43. Processing a new bank account application
requires some service coordination
Data
checking
Verify identity documents
Check address
Human review
List flagged applications
Handle human decisions
Account applications
Accept new application
Consolidate data checks
Human review?
Approve or reject
45. There are still a lot of things to think about
• Deployment and Infrastructure as code
• Secrets/configuration management
• Simplifying code management
• Debugging/troubleshooting
• Performance controls
• Security