22
Serverless On Stage Luca Bianchi Serverless User Group - Italy github.com/aletheia https://it.linkedin.com/in/lucabianchipavia @bianchiluca

Serverless On Stage - Serverless URL Shortener

Embed Size (px)

Citation preview

Serverless On Stage Luca Bianchi

Serverless User Group - Italy

github.com/aletheia

https://it.linkedin.com/in/lucabianchipavia

@bianchiluca

Welcome to the first Serverless On Stage Meetup!

• Born last June as an experiment (honestly after a number of beers..)

• 140 members in few months

• Monthly meetups (?) bi-monthly?

• Thanks to our sponsor that made it possible

• Paired with Serverless Office Hours (@goServerless, #Askserverless)

Serverless technologies are

• cool

• very fast evolving

• very bad documented

The most important thing about Serverless Italy Meetup

The most important thing about Serverless Meetup

• Join the discussion online

• Present topics at Serverless On Stage events • Give contributions and ideas

• Help spreading the word, save the world (from servers)!

www.neosperience.com | blog.neosperience.com | [email protected]

November 2015

Serverless 1.x - build services in days, not weeks

Luca Bianchi, Chief Technology Officer @ Neosperience

github.com/aletheia

https://it.linkedin.com/in/lucabianchipavia

@bianchiluca

CTO @ Neosperience

Who am I?

Working on a lot of bleeding edge technologies. Passionate developer. Love writing code, not Powerpoints.

The Neosperience Cloud• Software as a service cloud for Digital Customer Experience processes (couponing, gamification, proximity, etc.)

• Completely built on AWS

• Moved from VMWare, to EC2, to Elastic Beanstalk, to Lambda

• Dozens of micro and nano services

NeosperienceThe 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.

✓ Functions are the unit of development and scaling

✓ No machine, VMs or containers visible in the programming model

✓ Permanent storage lives elsewhere (stateless code)

✓ Scales per request. Users cannot over or under-provision capacity

✓ Never pay for idle

✓ Implicitly fault tolerant

✓ BYOC - Bring Your Own Code

✓ Metrics and logging are an universal right

The Serverless Manifesto

The Serverless Framework

• Started less than one year ago (was named JAWS)

• Provides an opinionated view of Serverless technologies • Fast moving (with a bi-weekly release model)

• Funded by a 3M investment • Manages service deployments and provisioning

• Vendor independent (in a future release)

The Serverless Framework 1.0

• One configuration file for everything

• Auto-provision of resources • Verbose output

• Supports for micro-services • Improved plugin management system

• Production ready

The Serverless Framework 1.1

• Services deployment rollback

• Allow services without functions • Functions can run locally

• Supports templates • Bug Fixes

Hello World!

• Install Serverless locally (trust me, it’s better) npm install serverless —save

• Create a function in NodeJS (also Java and Python are supported)serverless create —template=aws-nodejs

• Deploy serviceserverless deploy

done!

DEMO

Show me something more real!

• Marketing needs to track leads opening their links

• Standard trackers are “ugly” • You can pay bit.ly

• …or you can spend a few hours programming

• Show me the code!!

sls-url-shortener

Wait a minute.. let’s talk about architecture

• Dependency Injection

• Configuration injected • Each layer can be tested with a minimal amount of

mocks • AWS -independent

a layered model adapted for Serverless

Lambda Response Event

Lambda Request Event

Lambda Response Event

Lambda Request Event

handlerReceives Lambda event, handles AWS specific code and is injected with validator

validatorPerform event / input validation, enforcing constraints and rejecting invalid payloads. Additional permission checks should be implemented here

translatorConverts input data to business logic data, adding and building system consistent representation. Is injected with logic layer

logicImplements Business Logic for a specific service. Works on Business Objects, being an equivalent of MVC Service layer. Is injected with the adapter

adapterConverts data to a persistence actionable format, does not know about persistence concrete implementation, builds queries but does not initialize any connection to persistence. It is injected with repository.

repositoryImplements direct API calls to underlying persistence system

AWSAmazon Web Service persistence layer. It can be either dynamoDB, Redis, S3 or another microservice

DEMO

The good..

• Fast time to market (the whole project built in 8h)

• Modularity by design • Functions can run locally

• Everything is contained and versioned • Serverless avoids a lot of boilerplate

• Incremental deployments • Supports CI

• Enables services and infrastructure versioning • Cost-effective

..the bad..

• Architecture has to be enforced (your code is as good as you)

• Testing is unavoidable, TDD is encouraged • Every deploy hits the cloud

• Cannot test offline (no matter how you try) • Avoid Lambda cold start issue

• SLS Documentation is fragmented (now improved with 1.1) • Not everything is supported by CloudFormation

..the ugly!!

• Removed environment variables from 0.5 (!!)

• Sometimes CloudFormation hangs • YAML is not for humans (and Serverless does not support JSON anymore)

• You have to be an architect not (only) a developer • Avoid distributed monoliths

• Avoid “one big context variable”

Overall experience

• Faster time to market compared to standard stacks

• Unopinionated view on microservices, with a small opinionated layer (SLS) • It makes you a better developer

• Enforces creative solution finding (by opening a set of possibilities) • Supports CI

• Do not attempt manual deploy • Really Cost-effective

• Test coverage is a must

Thank you

github.com/aletheia

https://it.linkedin.com/in/lucabianchipavia

@bianchiluca

sls-url-shortener available on Github

https://github.com/aletheia/serverless-url-shortener

Slides available on Slideshare http://www.slideshare.net/aletheia1982/20161103-serverless-italy-meetup

www.neosperience.com | blog.neosperience.com | [email protected]