The serverless architecture of Instant. Based on our extensive blog post: https://blog.instant.cm/a-serverless-architecture-with-zero-maintenance-and-infinite-scalability-b00c2ceb4c2b#.fykihsl34
Website: https://instant.cm
2. 2
Why go serverless?
• 2 launching customers
• No idea about traction
• Didn’t want to spend money
• Didn’t want to do maintenance
• Lambda & API Gateway got launched
Crazy
Idea
Good
Idea
Magic zone
3. 3
Benefits of going serverless
• Zero maintenance
• No costs when there is no usage
• Never worry about scaling up (or down)
• Secure
Downsides
• Different way of programming
• Harder to make complex software
5. 5
AWS Lambda
• NodeJS, Java or Python
• Pay per 100ms usage
• Price depends on memory
allocation
• Free tier
• Connect to events in the AWS
“AWS Lambda lets you run code without
provisioning or managing servers. You pay
only for the compute time you consume —
there is no charge when your code is not
running.”
7. 7
API Gateway
• Define RESTful API endpoints
• Add/remove/modify headers
• CORS supported
• Connect endpoints to Lambda
functions
• Custom domain (api.teletext.io)
• IAM authentication supported
• Generate SDK for Android, iOS or
JavaScript
“Amazon API Gateway is a fully managed
service that makes it easy for developers to
create, publish, maintain, monitor, and
secure APIs at any scale.”
9. 9
AWS DynamoDB
• NoSQL service
• Verbose syntax - use libraries
• API Gateway -> Lambda ->
DynamoDB = 300~600ms
• Store data in S3 and serve through
CloudFront in 30~50ms
“Amazon DynamoDB is a fast and flexible
NoSQL database service for all applications
that need consistent, single-digit
millisecond latency at any scale. It is a fully
managed cloud database and supports
both document and key-value store
models.”
11. 11
AWS Cognito
• Google, Facebook, Twitter, Amazon
• Provides temporary IAM
credentials
• Supports custom OpenID
integrations
• Javascript on client connects to
Google API and Cognito
“Amazon Cognito lets you easily add user
sign-up and sign-in to your mobile and web
apps. With Amazon Cognito, you can also
authenticate users through social identity
providers such as Facebook, Twitter, or
Amazon, or by using your own identity
solution.”
12. 12
AWS Cognito
• Google passes you an id_token
• Pass the token to Cognito and it returns IAM credentials
• On API calls, pass the tokens to authenticate
• Double-check the Google token in your Lambda functions against their
certificate
• Lambda pro tip: use /tmp for local storage between function calls
13. 13
AWS S3 and CloudFront
• Static website hosting (html/js - ReactJs - Angular - Jekyll)
• ReactJs and connect to API Gateway
• Compile ReactJs to static site with webpack
• Add simple content management and multi language with teletext.io