Serverless
Obie Fernandez
Basics
serverless: pervasive
use of functional
computing resources
Backend as a
Service (BaaS)
Implementing server-side logic and
state primarily using third-party,
cloud-based services.
Main examples:
● Parse
● Firebase
Functions as a
Service (FaaS)
Custom, event-triggered backend code
deployed into stateless compute
containers fully managed by cloud
computing vendors.
Main examples:
● AWS Lambda
● IBM OpenWhisk
● Google Cloud Functions
● Azure Functions
Benefits of the approach
● No operating systems to choose, secure, patch, or manage.
● No servers to right size, monitor, or scale out.
● No risk to your cost by over-provisioning.
● No risk to your performance by under-provisioning.
But my favorite benefit has to
do with what it does to your
application architecture...
Microservices vs. Monoliths
Choosing microservice approach provides natural and compulsive incentive to
design components in a loosely-coupled, highly cohesive way
Image credit: http://martinfowler.com/articles/serverless.html
Image credit: http://martinfowler.com/articles/serverless.html
Drawbacks
● Additional complexity involved in programming and deployment versus
monolithic systems
● FaaS event-based, ephemeral (non-stateful) and resource constrained by
nature.
● Vendor lock-in
● Other limitations...
Execution Duration
Limited
Startup Latency
Integration Testing
Let’s talk about FaaS benefits again...
Optimization can drive cost savings
Any performance optimizations you make to your code will not only increase the
speed of your app but will also have a direct and immediate link to reduction in
operational costs
For example, if each of your operations currently take 1 second to run and you
reduce that to 200ms you’ll immediately see 80% savings in compute costs
without making any infrastructural changes.
Scale more cheaply
Jobs with very small load requirements can be broken down into microservices by
logic / domain even if the operational costs of such fine granularity might have
been otherwise prohibitive.
If your total workload is relatively small (but not entirely insignificant) you may not
need to pay for any compute at all due to the 'free tier' provided by some FaaS
vendors.
Example:
Inconsistent Traffic
Baseline traffic is 20 req/s but every 5
minutes spikes to 200 req/s for 10s.
Baseline performance maxes out your
server, but you don't want to reduce
response time during the traffic spikes.
Traditionally you increase your total
hardware capability by 10x to handle
the spikes, even though they only
account for less than 4% of uptime.
Auto-scaling not a good option due to
how long new instances of servers will
take to come up - by the time your new
instances have booted the spike phase
will be over.
Real-world Examples
Example: Video Uploader
Automates the video production process for
content producers.
Replaces manual Jenkins job with two lambdas that
automatically detect source file uploads, encode
them via Zencoder, and then register them with the
CMS so content producers can associate the
encoded videos with the proper courses and
content.
Less than 200 lines of code total.
Example: PennStation
Automates faculty onboarding
● Creation of LMS account
● Creation of primary and backup
Adobe Connect rooms
● Creation of primary and backup
conference phone lines
● Attachment of the lines to the rooms
The tasks that comprise PennStation's behavior are
controlled by an underlying directed graph, in which each
task is a node. The graph's edges determine which tasks execute.
Extra Topics
Extra Topic: Programming without
local state
For any given invocation of a function,
none of the in-process or host state
that you create will be available to any
subsequent invocation.
Twelve-factor processes are stateless
and share-nothing. Any data that
needs to persist must be stored in a
stateful backing service, typically a
database.
-- The Twelve-Factor App
Extra Topic:
Tooling
● Serverless Framework
● Apex
● Gordon
● Roll-your-own
Learn more...
My book is available at
Leanpub
http://leanpub.com/serverless
Serverless Meetup
NYC
http://meetup.com/Serverless-NYC

Liquid Day - Serverless

  • 1.
  • 3.
  • 4.
    serverless: pervasive use offunctional computing resources
  • 5.
    Backend as a Service(BaaS) Implementing server-side logic and state primarily using third-party, cloud-based services. Main examples: ● Parse ● Firebase
  • 6.
    Functions as a Service(FaaS) Custom, event-triggered backend code deployed into stateless compute containers fully managed by cloud computing vendors. Main examples: ● AWS Lambda ● IBM OpenWhisk ● Google Cloud Functions ● Azure Functions
  • 7.
    Benefits of theapproach ● No operating systems to choose, secure, patch, or manage. ● No servers to right size, monitor, or scale out. ● No risk to your cost by over-provisioning. ● No risk to your performance by under-provisioning.
  • 8.
    But my favoritebenefit has to do with what it does to your application architecture...
  • 10.
    Microservices vs. Monoliths Choosingmicroservice approach provides natural and compulsive incentive to design components in a loosely-coupled, highly cohesive way
  • 11.
  • 12.
  • 13.
    Drawbacks ● Additional complexityinvolved in programming and deployment versus monolithic systems ● FaaS event-based, ephemeral (non-stateful) and resource constrained by nature. ● Vendor lock-in ● Other limitations...
  • 14.
  • 15.
  • 16.
  • 17.
    Let’s talk aboutFaaS benefits again...
  • 18.
    Optimization can drivecost savings Any performance optimizations you make to your code will not only increase the speed of your app but will also have a direct and immediate link to reduction in operational costs For example, if each of your operations currently take 1 second to run and you reduce that to 200ms you’ll immediately see 80% savings in compute costs without making any infrastructural changes.
  • 19.
    Scale more cheaply Jobswith very small load requirements can be broken down into microservices by logic / domain even if the operational costs of such fine granularity might have been otherwise prohibitive. If your total workload is relatively small (but not entirely insignificant) you may not need to pay for any compute at all due to the 'free tier' provided by some FaaS vendors.
  • 20.
    Example: Inconsistent Traffic Baseline trafficis 20 req/s but every 5 minutes spikes to 200 req/s for 10s. Baseline performance maxes out your server, but you don't want to reduce response time during the traffic spikes. Traditionally you increase your total hardware capability by 10x to handle the spikes, even though they only account for less than 4% of uptime. Auto-scaling not a good option due to how long new instances of servers will take to come up - by the time your new instances have booted the spike phase will be over.
  • 21.
  • 24.
    Example: Video Uploader Automatesthe video production process for content producers. Replaces manual Jenkins job with two lambdas that automatically detect source file uploads, encode them via Zencoder, and then register them with the CMS so content producers can associate the encoded videos with the proper courses and content. Less than 200 lines of code total.
  • 25.
    Example: PennStation Automates facultyonboarding ● Creation of LMS account ● Creation of primary and backup Adobe Connect rooms ● Creation of primary and backup conference phone lines ● Attachment of the lines to the rooms The tasks that comprise PennStation's behavior are controlled by an underlying directed graph, in which each task is a node. The graph's edges determine which tasks execute.
  • 26.
  • 27.
    Extra Topic: Programmingwithout local state For any given invocation of a function, none of the in-process or host state that you create will be available to any subsequent invocation. Twelve-factor processes are stateless and share-nothing. Any data that needs to persist must be stored in a stateful backing service, typically a database. -- The Twelve-Factor App
  • 28.
    Extra Topic: Tooling ● ServerlessFramework ● Apex ● Gordon ● Roll-your-own
  • 29.
    Learn more... My bookis available at Leanpub http://leanpub.com/serverless Serverless Meetup NYC http://meetup.com/Serverless-NYC