Slides from my talk on functions-as-a-service at Wyncode Academy in Miami in April '18. Provides an overview of the tradeoffs between different FaaS providers
1. A Gentle Introduction to
Functions-as-a-Service
Valeri Karpov
@code_barbarian
github.com/vkarpov15
2. About Me
● Backend Lead @ Booster, Node.js OSS
● Core contributor for Mongoose, Mocha
● Blogger, thecodebarbarian.com
● Early employee at LevelUp, MongoDB, Booster
● Invented the MEAN stack
3. What’s This Talk About?
● The progression of dev-ops for startups
● Why FaaS is the next natural step for dev-ops
● Retaining state in “stateless” functions
● Trade-offs between different FaaS providers
4. 2008: Physical Machine in Dorm Room
● EC2 was limited, other hosting services sucked
● LevelUp’s first release on an Ubuntu tower
○ Physical machines die or get shut down
○ Campus ISP is slow or changes the IP
○ Limited scale: shipping a new PC takes days
5. 2012: Amazon EC2
● My next few startups all ran on 1-5 EC2 VMs
● Cloud VMs solve most physical machine issues
○ Power outages much less likely
○ Reliable internet maintained by Amazon
○ Spinning up a new VM takes minutes
6. 2012: Amazon EC2
● Vanilla EC2 was great for single server apps
● But what about multiple app servers?
○ 2 services on the same VM in isolation
○ Continuous Deployment
○ Scaling horizontally with a click
7. 2015: Containers and Orchestration
● Docker, Mesos, Kubernetes, etc.
● Compelling for CD and isolation
● Still Have Problems with Resource Usage
○ Memory limits per VM
○ Docker hogs disk space
8. Functions as a Service
● Instead of deploying an app, you deploy a
bunch of stateless functions
● No VMs, no OS updates
● Resource limits (RAM, CPU) per function call
● Functions run in response to triggers
9. API Gateways
● Cloud functions respond to triggers
● HTTP is a trigger, but what about:
○ API keys / auth
○ Rate limits
● FaaS providers have API Gateways for this
10. FaaS Providers
● Amazon AWS Lambda
● Microsoft Azure Functions
● Google Cloud Functions
● IBM Cloud Functions
● Oracle Cloud Fn
● LunchBadger, + many more
12. FaaS Advantages
● Easier to scale, no need to worry about too
much load on one service
● Cheaper for low-usage services
● Cheap and easy development environments
● Resource issues rare and easy to debug
13. FaaS Problems
● No strong best practices yet
● Completely different way of writing apps
● Limited language support
● Managing triggers and API Gateways
● Sometimes you want to retain state...
15. Stateless is a Big Performance Problem
● Connecting to a database on every function
call is slow
16. But You Can Retain Global State
● Put db handle in global scope
17. Common Trick Across FaaS Providers
● AWS Lambda: bit.ly/mongodb-lambda
● Azure Functions: bit.ly/mongodb-azure
○ Also With C#: bit.ly/csx-azure-state
● IBM Cloud: bit.ly/mongodb-ibm-cloud
21. Hidden Fees: API Gateways
● AWS Lambda: $3.50 / 1M + data
● Azure Functions: no extra cost necessary
● Google Cloud Functions: no extra cost
necessary