4. Architecture Archeology - Client server
A fat do-it-all Server
Mostly on-premises server
Upfront investment
Capacity planning
Scaling was a nightmare
5. Cloud based architectures
+ Servers can be disposable, unless
they’re snowflakes
+ Application architecture can make
scaling easier or more difficult
- Capacity planning still required
- Still pay ($$) if your server is idle
6. Capacity planning
How many servers?
How powerful?
How much memory?
What do we do with excess resources?
What if we have too little resources?
How do we (dynamically) grow or shrink resources?
Resources become obsolete
What if we suffer the Slashdot effect?
7. Serverless: a very simple yet powerful idea
● You submit units of work for execution
● Pay only for computing time you consume
● A.k.a. Function as a Service: FAAS
9. What does Serverless mean for you?
● Less Work
○ No need to run servers in premises
○ No need to manage servers in the cloud (admin, patches)
○ No need to plan capacity or scaling
● Potential money savings
○ Only pay for computing time you use
10. Why does it make me excited
● I’m an aging developer
11. Why does serverless make me excited?
● I’m an aging developer
● Potentially unlimited scaling
● Computing resources are
disposable
● Low level maintenance is
abstracted out…
● (it’s somebody else’s problem)
● IT assets are programmable
32. Precondition to run the exercises
tree ~/.aws cat ~/.aws/config
[default]
region = eu-west-1
cat ~/.aws/credentials
[default]
aws_access_key_id = SOME_ID
aws_secret_access_key = AKEY
34. What is zappa?
● A python framework for serverless applications
● Used as command line tool
● Manages application lifecycle
○ Creation
○ Deploy
○ Update
○ Undeploy Configure Deploy Test
36. zappa init
● Optional
● Initializes project
● Creates zappa_settings.json file
● YAML format also available
Configure Deploy Test
37. Zappa code looks like Flask
● example.py
● zappa_settings.json
Configure Deploy Test
38. zappa deploy dev
Calling deploy for stage dev..
Downloading and installing dependencies..
Packaging project as zip.
Uploading servless-dev-1506419080.zip (5.9MiB)..
100%|███████████████| 6.16M/6.16M [00:01<00:00, 2.16MB/s]
Scheduling..
Scheduled servless-dev-zappa-keep-warm-handler.keep_warm_callback
with expression rate(4 minutes)!
TestConfigure Deploy Test
39. zappa deploy dev
Uploading servless-dev-template-1506419092.json (1.6KiB)..
100%|███████████████| 1.61K/1.61K [00:00<00:00, 3.71KB/s]
Waiting for stack servless-dev to create (this can take a bit)..
75%|███████████▎ | 3/4 [00:09<00:04, 4.94s/res]
Deploying API Gateway..
Deployment complete!:
https://x0doi1ioid.execute-api.eu-west-1.amazonaws.com/dev
TestConfigure Deploy Test
40. zappa deploy dev
Uploading servless-dev-template-1506419092.json (1.6KiB)..
100%|███████████████| 1.61K/1.61K [00:00<00:00, 3.71KB/s]
Waiting for stack servless-dev to create (this can take a bit)..
75%|███████████▎ | 3/4 [00:09<00:04, 4.94s/res]
Deploying API Gateway..
Deployment complete!:
https://x0doi1ioid.execute-api.eu-west-1.amazonaws.com/dev
TestConfigure Deploy Test
43. Other commands
zappa tail
● Show latest logs
zappa update dev
● Update code and
settings
zappa undeploy dev
● Remove lambda
function
● Remove AWS API
Gateway
47. Why API Gateway?
● Interoperability
○ It’s only JSON over HTTP
○ Other platforms
○ Other AWS technologies
○ Other languages
○ Clients not tied to boto
● RESTful API
● Request Throttling/Limits
● Authorization tokens
49. Pitfalls
● 300 seconds execution time limit
● Calls must be stateless
● Cold start for 1st request -> Keep warm calls
○ An computing instance must be started
○ Can also happen during low traffic periods
● Logging only to CloudWatch
50. Pitfalls
● Fragmentation in a myriad of microservices
● Data leaves Switzerland
● Flame wars
○ 1 (Git) repository per service
○ All services in 1 (Git) repository
● Potential vendor lock-in
● Flow control and error handling gets tricky
51. The upsell - AWS Steps Functions
● Orchestration of Lambdas
57. Edge Locations
● AWS CloudFront: Amazon’s CDN
● Content served by edge location
closest to client
○ Images
○ Pages
○ Streams
58. Edge Locations
● AWS CloudFront: Amazon’s CDN
● Content served by edge location
closest to client
○ Images
○ Pages
○ Streams
59. Lambda Functions deployed into Regions
● Or, into a EC2 instance < AZ < Region
● High latency on requests from distant
areas
60. AWS Lambda@Edge
● Lambdas deployed to edge
locations
● Requests to Lambdas served by
closest (edge) location
● Lambda is automatically run
@edge, no provisioning needed
61. AWS Lambda pricing
Requests
First 1 million requests
per month are free
$0.20 per 1 million
requests thereafter
($0.0000002 per request)
Duration
Billing rounded up to the
nearest 100ms
Depending on the
amount of allocated
memory
Other
Data transfer (external)
Data storage
AWS API Gateway, $3.50
per million API calls
received