SlideShare a Scribd company logo
Serverless URL Shortener
Serverless Brainpirlo
Luca Bianchi — Neosperience
github.com/aletheia
it.linkedin.com/in/lucabianchipavia
@bianchiluca
medium.com/@aletheia
Who am I?
• Chief Technology Officer @ Neosperience
• Working on a lot of bleeding edge technologies
• Passionate developer: love writing code, hate meetings
The Neosperience Cloud
• Software as a service cloud for Digital Customer Experience processes 

(Psychographics, Loyalty & Gamification, Proximity, Content, etc.)
• Built on AWS, 95% on Serverless technologies
• Moved from VMWare, to EC2, to Elastic Beanstalk, to Serverless
• Dozens of micro and nano services
The Digital Customer Experience Company, aims to change the way brands and
customers interact with an approach of a software vendor targeting Digital
Customer Experience as the evolution of Marketing automation.
Serverless Meetup
Began as a joke, after too many beers
456 members and growing
Hosted the first italian JeffConf 

(https://goo.gl/mqvnsR)
Monthly meetup
Events with other communities
Wants to build a network of 

serverless meetups
Serverless Meetup
meetup.com/serverless-italy
Call For Speakers!
clda.co/serverless-italy
Agenda
“Serverless” disclaimer
What is “Serverless”?
The Serverless Manifesto
Events, streams and triggers
Serverless development, tools and vendors
Use Case: your nightmare before Christmas
The good, the bad and the ugly of Serverless development
A point on Serverless architectures
20180111   we bde-bs - serverless url shortener
A “Serverless” disclaimer
“There is always a server somewhere,

you just don't have to worry about it =)”
What is Serverless?
“Serverless architecture replaces long-running virtual machines with ephemeral compute
power that comes into existence on request and disappears immediately after use.
Use of this architecture can mitigate some security concerns such as security patching and
SSH access control, and can make much more efficient use of compute resources. These
systems cost very little to operate and can have inbuilt scaling features.”
— ThoughtWorks, 2016
The Serverless Manifesto
Function as the unit of deployment and scaling
Implicitly fault-tolerant
Metrics
No machines, VMs, or containers
Bring Your Own Code
Stateless
Never pay for idle
Scales per request
It all started with an event..
• events are a great way to decouple services
• largely abused in the last decade (ESB)
• now revamped with CQRS and Event Sourcing
to handle microservices communication
• serverless functions handle events
• need a different approach on architectures
AWS Lambda is a compute service that lets you run code without provisioning or managing servers. AWS Lambda
executes your code only when needed and scales automatically, from a few requests per day to thousands per
second.

Service released on Nov, 2014

Introduces Event-Driven programming model

Provides a context and an event object
AWS Lambda
Running a Lambda Function
Supported Languages
CloudFormation
Cloud Services become a part of your project
Infrastructure-as-code
A scripting language for the cloud
Defines AWS resources 

(Lambda, S3Buckets, DynamoTables, etc)
Manages resource lifecycle
Example: creating a DynamoDB Table
https://docs.aws.amazon.com/AWSCloudFormation/
latest/UserGuide/Welcome.html
Serverless
20180111   we bde-bs - serverless url shortener
DEMO
AWS SAM
“Serverless Application Model”
What is AWS SAM?
github.com/awslabs/serverless-application-model
“The goal of AWS SAM is to define a
standard application model for
serverless applications.”
In other (technical) words?
AWS::Serverless Transform
(CloudFormation)
Special serverless resources
(e.g.
AWS::Serverless::Function)
Pretty similar to Serverless
Framework’s syntax (yaml)
Natively supported by AWS SAM
Local
(github.com/awslabs/aws-sam-local)
AWS SAM Example (Function)
(plus policies, VCP config, DLQ, tracing, etc.)
AWS SAM Example (Traffic Shifting)
(plus alarms & pre/post-traffic hooks)
AWS SAM Example (DynamoDB)
AWS SAM Example (API Gateway)
(plus cache, stage variables, etc.)
AWS SAM Example (Function+API)
My Personal “wishes” for AWS SAM
More transparency (make it public, or even customizable?)
Custom Transforms (endless possibilities!)
A Christmas Nightmare
It is the night before Christmas 

and you’re just leaving..
…then your manager steps into the office..
…with another great idea: 

an url-tracker!
your reaction…
IDEA: Make it Serverless!
Focus only on your code
No infrastructure to manage (your IT guy has a family, too)
Scales up to production requirements
Can be released within minutes
Use DynamoDB and GSI
Serverless does not mean spaghetti-code!
Serverless URL-Tracker
20180111   we bde-bs - serverless url shortener
CODE
We did it!!
The good
Fast deployments
Serverless.yml makes things easy
Infrastructure versioning
Test environments
IAM permissions management
DynamoDB scales automatically
Serverless strips unwanted dependencies
A/B testing with Lambda is very easy
Progressive rollout are made possible with a single click
The bad
CloudFormation is not so easy to write
Not every service is scriptable
Support for 3rd party services is very bad
No Lambda lifecycle callbacks
Lambda cold start matters
No GPU support (yet)
Serverless Framework is not an AWS tool
The ugly
Lambda support is up to NodeJS 6.10
Maximum resorce limit up to 200
CloudFront distribution needs some tune-up
Communication between Lambdas is up to you
Download my profile
We did it!!
About architectures
About architectures
“Bad code haunts you for months…
..bad architectures harms you for decades.”
• In 2015 Tim Wagner, General Manager @ AWS Serverless Compute,
presented to the ServerlessConf the so-called Serverless Manifesto.
• In 2017 Danilo Poccia, Technical Evangelist @ AWS, talking at
JeffConf asked “what would be having that manifesto translated into a
checklist to evaluate Serverless compliance of an architecture?”
• So, we turned it into a “Serverless Scorecard”
Evaluating a serverless architecture
(aka how big is my serverless?)
The Serverless Scorecard
Function as the unit of deployment and scaling
Implicitly fault-tolerant
Metrics
No machines, VMs, or containers
Bring Your Own CodeStateless
Never pay for idleScales per request
An IDE for Serverless?
20180111   we bde-bs - serverless url shortener
20180111   we bde-bs - serverless url shortener
20180111   we bde-bs - serverless url shortener
AWS Cloud9 Features
Full-fledged IDE & Dev tools
Cost-saving settings (hibernation)
Integrated web terminal *
(EC2 or SSH environment)
Built-in Lambda support
Live debugging capabilities
(only Node.js for now)
Collaborative coding/debugging
* No SSH keys or IAM
credentials to configure locally (!)
SAM-local integration
(local testing & deployments)
AWS Cloud9 Dev Tools
AWS CLI (1.11), sam-local (0.2.4)
git, gcc, c++, Docker (17.03)
node (6.11.4), npm, nvm, coffeescript
python (2.7.12 & 3.6.2), virtualenv, pip,
pylint, boto3
PHP (5.6), MySQL (14.14), Apache (2.4)
ruby (2.4.1), rails (5.1.4)
Go (1.9.1)
Java
docs.aws.amazon.com/cloud9/latest/user-guide/ami-contents.html
AWS Cloud9 Look&Feel
AWS Cloud9 Limitations & “wishes”
Max 20 env per user, 100 per account
Max 10 open env per user
Max 8 members in each env
EC2 instance maintenance is still
on you (OS updates, etc.)
No Python debugging 🐍
No “offline” support 📡
Only SAM-focused 🐿
Lacking AWS Console integration
“Primitive" Lambda testing ⚡
(e.g. no event generation)
One more thing…
http://bit.ly/sls-starter
One more thing…
starter-serverless-nodejs
slides @ http://bit.ly/sls-20180111
code @ https://github.com/waylon-ai/waylon-url-shortener

More Related Content

20180111 we bde-bs - serverless url shortener

  • 1. Serverless URL Shortener Serverless Brainpirlo Luca Bianchi — Neosperience github.com/aletheia it.linkedin.com/in/lucabianchipavia @bianchiluca medium.com/@aletheia
  • 2. Who am I? • Chief Technology Officer @ Neosperience • Working on a lot of bleeding edge technologies • Passionate developer: love writing code, hate meetings The Neosperience Cloud • Software as a service cloud for Digital Customer Experience processes 
 (Psychographics, Loyalty & Gamification, Proximity, Content, etc.) • Built on AWS, 95% on Serverless technologies • Moved from VMWare, to EC2, to Elastic Beanstalk, to Serverless • Dozens of micro and nano services The Digital Customer Experience Company, aims to change the way brands and customers interact with an approach of a software vendor targeting Digital Customer Experience as the evolution of Marketing automation.
  • 3. Serverless Meetup Began as a joke, after too many beers 456 members and growing Hosted the first italian JeffConf 
 (https://goo.gl/mqvnsR) Monthly meetup Events with other communities Wants to build a network of 
 serverless meetups
  • 4. Serverless Meetup meetup.com/serverless-italy Call For Speakers! clda.co/serverless-italy
  • 5. Agenda “Serverless” disclaimer What is “Serverless”? The Serverless Manifesto Events, streams and triggers Serverless development, tools and vendors Use Case: your nightmare before Christmas The good, the bad and the ugly of Serverless development A point on Serverless architectures
  • 7. A “Serverless” disclaimer “There is always a server somewhere,
 you just don't have to worry about it =)”
  • 8. What is Serverless? “Serverless architecture replaces long-running virtual machines with ephemeral compute power that comes into existence on request and disappears immediately after use. Use of this architecture can mitigate some security concerns such as security patching and SSH access control, and can make much more efficient use of compute resources. These systems cost very little to operate and can have inbuilt scaling features.” — ThoughtWorks, 2016
  • 9. The Serverless Manifesto Function as the unit of deployment and scaling Implicitly fault-tolerant Metrics No machines, VMs, or containers Bring Your Own Code Stateless Never pay for idle Scales per request
  • 10. It all started with an event.. • events are a great way to decouple services • largely abused in the last decade (ESB) • now revamped with CQRS and Event Sourcing to handle microservices communication • serverless functions handle events • need a different approach on architectures
  • 11. AWS Lambda is a compute service that lets you run code without provisioning or managing servers. AWS Lambda executes your code only when needed and scales automatically, from a few requests per day to thousands per second. Service released on Nov, 2014 Introduces Event-Driven programming model Provides a context and an event object AWS Lambda
  • 12. Running a Lambda Function
  • 14. CloudFormation Cloud Services become a part of your project Infrastructure-as-code A scripting language for the cloud Defines AWS resources 
 (Lambda, S3Buckets, DynamoTables, etc) Manages resource lifecycle Example: creating a DynamoDB Table https://docs.aws.amazon.com/AWSCloudFormation/ latest/UserGuide/Welcome.html
  • 17. DEMO
  • 19. What is AWS SAM? github.com/awslabs/serverless-application-model “The goal of AWS SAM is to define a standard application model for serverless applications.”
  • 20. In other (technical) words? AWS::Serverless Transform (CloudFormation) Special serverless resources (e.g. AWS::Serverless::Function) Pretty similar to Serverless Framework’s syntax (yaml) Natively supported by AWS SAM Local (github.com/awslabs/aws-sam-local)
  • 21. AWS SAM Example (Function) (plus policies, VCP config, DLQ, tracing, etc.)
  • 22. AWS SAM Example (Traffic Shifting) (plus alarms & pre/post-traffic hooks)
  • 23. AWS SAM Example (DynamoDB)
  • 24. AWS SAM Example (API Gateway) (plus cache, stage variables, etc.)
  • 25. AWS SAM Example (Function+API)
  • 26. My Personal “wishes” for AWS SAM More transparency (make it public, or even customizable?) Custom Transforms (endless possibilities!)
  • 28. It is the night before Christmas 
 and you’re just leaving.. …then your manager steps into the office.. …with another great idea: 
 an url-tracker!
  • 30. IDEA: Make it Serverless! Focus only on your code No infrastructure to manage (your IT guy has a family, too) Scales up to production requirements Can be released within minutes Use DynamoDB and GSI Serverless does not mean spaghetti-code!
  • 33. CODE
  • 35. The good Fast deployments Serverless.yml makes things easy Infrastructure versioning Test environments IAM permissions management DynamoDB scales automatically Serverless strips unwanted dependencies A/B testing with Lambda is very easy Progressive rollout are made possible with a single click
  • 36. The bad CloudFormation is not so easy to write Not every service is scriptable Support for 3rd party services is very bad No Lambda lifecycle callbacks Lambda cold start matters No GPU support (yet) Serverless Framework is not an AWS tool
  • 37. The ugly Lambda support is up to NodeJS 6.10 Maximum resorce limit up to 200 CloudFront distribution needs some tune-up Communication between Lambdas is up to you
  • 41. About architectures “Bad code haunts you for months… ..bad architectures harms you for decades.”
  • 42. • In 2015 Tim Wagner, General Manager @ AWS Serverless Compute, presented to the ServerlessConf the so-called Serverless Manifesto. • In 2017 Danilo Poccia, Technical Evangelist @ AWS, talking at JeffConf asked “what would be having that manifesto translated into a checklist to evaluate Serverless compliance of an architecture?” • So, we turned it into a “Serverless Scorecard” Evaluating a serverless architecture (aka how big is my serverless?) The Serverless Scorecard Function as the unit of deployment and scaling Implicitly fault-tolerant Metrics No machines, VMs, or containers Bring Your Own CodeStateless Never pay for idleScales per request
  • 43. An IDE for Serverless?
  • 47. AWS Cloud9 Features Full-fledged IDE & Dev tools Cost-saving settings (hibernation) Integrated web terminal * (EC2 or SSH environment) Built-in Lambda support Live debugging capabilities (only Node.js for now) Collaborative coding/debugging * No SSH keys or IAM credentials to configure locally (!) SAM-local integration (local testing & deployments)
  • 48. AWS Cloud9 Dev Tools AWS CLI (1.11), sam-local (0.2.4) git, gcc, c++, Docker (17.03) node (6.11.4), npm, nvm, coffeescript python (2.7.12 & 3.6.2), virtualenv, pip, pylint, boto3 PHP (5.6), MySQL (14.14), Apache (2.4) ruby (2.4.1), rails (5.1.4) Go (1.9.1) Java docs.aws.amazon.com/cloud9/latest/user-guide/ami-contents.html
  • 50. AWS Cloud9 Limitations & “wishes” Max 20 env per user, 100 per account Max 10 open env per user Max 8 members in each env EC2 instance maintenance is still on you (OS updates, etc.) No Python debugging 🐍 No “offline” support 📡 Only SAM-focused 🐿 Lacking AWS Console integration “Primitive" Lambda testing ⚡ (e.g. no event generation)
  • 53. slides @ http://bit.ly/sls-20180111 code @ https://github.com/waylon-ai/waylon-url-shortener