1. Stateless
2. Infinitely Scalable
3. Perfect for short jobs
4. Chainable/Composable
5. Responsive to events
also cheap (per per use) & fully managed
Request
API Gateway
FaaS
GET /products
GET /products/:id
GET /cart
GET /user
GET /categories
GET /products
GET /products/:id
GET /cart
GET /user
GET /user/:id
getAllProducts
getProductById
getCartContents
getUserDetails
getUserById
GET /products
GET /products/:id
GET /cart
GET /user
GET /user/:id
productsService
- getAllProducts
- getProductById
cartService
- getCartContents
userService
- getUserDetails
- getUserById
GET /products
GET /products/:id
GET /cart
GET /user
GET /user/:id
-getAllProducts
-getProductById
-getCart Contents
-getUserDetails
-getUserById
POST /graphql
{
products(category: "book") {
name
description
price
}
}
AppSync GraphQL
endpoint
DynamoDB
complexity
customizability
Nanoservices
AppSync
Microservices
Monolith
Go Nanoservices if you need flexibility
- function level configuration
- separation of concerns, single responsibility principle
- better security
- smaller code size = faster deployments, faster cold boot
- more granular unit deployment
- probably most popular
Go Microservices if you need a bit less flexibility and less configuration burden
Don't waste time for Monoliths
AppSync for the win
- even frontend devs can handle it
- uses GraphQL = easier to handle on the frontend
- awesome out of the box
- robust queries (filtering, sorting, fuzzy searching etc.)
- realtime updates & offline support
- authorizers
- resolvers work magically with multiple data sources
GET /me
Context
Principal + Policy
Allowed
Denied 403
Auth Function
DB
Gateway
Load Balancer
Legacy App
New Serverless App
Client
Function
Client
Function
Queue
CloudWatch Event
(scheduled every X hours)
Dump Table
Move S3 Images
3rd party API
...
S3 Bucket
on file uploaded
SQS Queue
receive message
retrieve original file, modify and re-upload
Encoder
S3 Bucket
on file uploaded
SQS Queue
receive message
retrieve original file, create thumbnail, upload to /thumbnails/:userId
Encoder
on thumbnail uploaded
SQS Queue
User Updater
receive message
update User where id = m.userId
DB Table
Events Collector
(e.g. analytics events)
Website 1
Gateway
Website 3
Website 2
Database
Events Collector
(e.g. analytics events)
Website 1
Gateway
Website 3
Website 2
Database
...
Error: Too many connections
Events Collector
Website 1
Gateway
Website 3
Website 2
Database
Injector
(batch size = 100)
SQS
1. Stateless
2. Infinitely Scalable
3. Perfect for short jobs
4. Chainable/Composable
5. Responsive to events
also cheap (per per use) & fully managed
Dispatcher
Workers
...
Dispatcher & Reducer
Workers
...
user.id = 1 - 100
API Callers
...
user.id = 100-200
user.id = 200-300
user.id = ...
Every hour
Get all users from db and Dispatch API call jobs
Crawling instagram N profiles and dumping them to s3 every hour
Database
API Call
S3
images
Images
API Call
Images
API Call
Images
API Call
Images
Splitter
N Mappers
...
SQS
Reducer
Input Data
batch_size = n
IoT Device
MQTT
Kinesis Firehose
Kinesis Stream
Transformer
Database
Notifier
SNS Topic
Dump / Reporting
S3
AppSync
Kinesis Firehose
Kinesis Stream
Deduplication
Database with TTL
Input Stream
Final DB