A story about
Vacation Tracker
a 100% serverless startup
Slide 3
Slide 3 text
A story about
Vacation Tracker
a 100% serverless startup
Slide 4
Slide 4 text
A story about
Vacation Tracker
a 100% serverless startup
Slide 5
Slide 5 text
A story about
Vacation Tracker
a 100% serverless startup
Slide 6
Slide 6 text
A story about
Vacation Tracker
a 100% serverless startup
Slide 7
Slide 7 text
A story about
Vacation Tracker
a 100% serverless startup
Slide 8
Slide 8 text
In 2016 we decided to build
a leave tracking system
a leave tracking system
Slide 9
Slide 9 text
In 2016 we decided to build
a leave tracking system
To solve our own leave tracking problem
Slide 10
Slide 10 text
In 2016 we decided to build
a leave tracking system
2017
To solve our own leave tracking problem
Slide 11
Slide 11 text
In 2016 we decided to build
a leave tracking system
2017
2018
To solve our own leave tracking problem
Slide 12
Slide 12 text
The idea was simple:
- track leave requests and number of remaining days
- use some SSO, so we do not n!d to remember more passwords
- connect to Slack so that we can have the info in Slack
- connect to the calendar so we can subscribe to events
Slide 13
Slide 13 text
We were solving our problem
but we were not sure if anyone else will use it
Slide 14
Slide 14 text
- startups
- sma" companies
- schools
- non-profits
- teams from enterprises
- government organizations
- churches
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
The number of unique users by December 1st
263623
Slide 17
Slide 17 text
The dashboard
Slide 18
Slide 18 text
Slack
Slide 19
Slide 19 text
Microsoft Teams
Slide 20
Slide 20 text
The architecture v0.1
A simple serverless bot
Slide 21
Slide 21 text
No content
Slide 22
Slide 22 text
Why serverless?
Slide 23
Slide 23 text
From 1 to 101
Lambda Functions
in Production
Evolving a Serverless Architecture
Slide 24
Slide 24 text
@slobodan_
Before we continue…
Slide 25
Slide 25 text
Slobodan Stojanović
CTO @ Cloud Horizon & CTO @ Vacation Tracker
co-author of Serverless Applications with Node.js book
AWS Serverless Hero
https://slobodan.me
Slide 26
Slide 26 text
Why serverless?
Slide 27
Slide 27 text
s
e
r
v
e
r
l
e
s
s
Slide 28
Slide 28 text
s
e
r
v
e
r
l
e
s
s
low
Slide 29
Slide 29 text
s
e
r
v
e
r
l
e
s
s
low
xpensive
Slide 30
Slide 30 text
s
e
r
v
e
r
l
e
s
s
low
xpensive
endor lock-in
Slide 31
Slide 31 text
s
e
r
v
e
r
l
e
s
s
low
xpensive
endor lock-in
Slide 32
Slide 32 text
Serverless because:
- Sma" team without devops experience
- AUTO SCALABLE
- Cheap
- Fast to build a prototype
- Secure
Slide 33
Slide 33 text
But it wasn't 100% "serverless"
Slide 34
Slide 34 text
No content
Slide 35
Slide 35 text
No content
Slide 36
Slide 36 text
- Quick and independent deployments
- Easy to understand and maintain
- Easy to onboard new people
- Cheap
Benefits:
Slide 37
Slide 37 text
The Cost: $0/month
Slide 38
Slide 38 text
Adding new features?
Slide 39
Slide 39 text
No content
Slide 40
Slide 40 text
No content
Slide 41
Slide 41 text
- Independent deployments
- Hard to manage
- Hard to scale
- A bottleneck
Downsides:
Slide 42
Slide 42 text
~ 100 paying teams
Slide 43
Slide 43 text
The architecture v1.0
A complex serverless application
Slide 44
Slide 44 text
Infrastructure-as-a-Code
Slide 45
Slide 45 text
Service Service
(micro?) (micro?)
Slide 46
Slide 46 text
No content
Slide 47
Slide 47 text
~150 Lambda functions
Slide 48
Slide 48 text
FIRST MIGRATIONS
(FROM AN OLD SERVICE TO A NEW ONE)
Slide 49
Slide 49 text
Finding a good architecture
Slide 50
Slide 50 text
- Everything is in IaaC CloudFormation
- Replaced Node.js server with serverless services
- Added TypeScript
- Replaced MongoDB with DynamoDB
Things we changed:
- Storing state not events
- Wasting time on less important things
- Hard to onboard new developers
- Many new services
Downsides:
Slide 53
Slide 53 text
- Storing state not events
- Wasting time on less important things
- Hard to onboard new developers
- Many new services
- Developers don't like YAML :)
Downsides:
Slide 54
Slide 54 text
~ 600 paying teams
Slide 55
Slide 55 text
The architecture v2.0
An event driven system
Slide 56
Slide 56 text
Finding a good architecture v2.0
Slide 57
Slide 57 text
Command Query Responsibility Segregation (CQRS)
Slide 58
Slide 58 text
Why CQRS?
Slide 59
Slide 59 text
Storing the state vs storing the events
Slide 60
Slide 60 text
- Ana created a location and moved John and Mike
- Ana assigned Mike as an approver
- Ana assigned a leave policy (20 PTO days per year)
- John requested a leave, Ana approved
- Ro"over, some unused days were transferred to the next year
- Ana changed John's working w!k
- Mike added some past leaves for John
- Alex transferred John to another location with different policy
- …
Slide 61
Slide 61 text
A quiz question:
Calculate John's remaining PTO days for 2021
Slide 62
Slide 62 text
CQRS to the rescue
Slide 63
Slide 63 text
Mutation Event storage
Subscription
Query
Read-only table
EventBridge
Business logic Business logic
AWS AppSync
Slide 64
Slide 64 text
Mutation Event storage
Subscription
Query
Read-only table
EventBridge
Business logic Business logic
AWS AppSync
Slide 65
Slide 65 text
Mutation Event storage
Subscription
Query
Read-only table
EventBridge
Business logic Business logic
AWS AppSync
Slide 66
Slide 66 text
112 Lambda functions
Slide 67
Slide 67 text
- Fu"y Managed GraphQL
- Less code
- Better control
- A" benefits from the previous architecture
- Monorepo
Benefits:
Slide 68
Slide 68 text
- More new services to learn
- Velocity templates
Downsides:
Slide 69
Slide 69 text
Challenges
Slide 70
Slide 70 text
Onboarding new developers
Slide 71
Slide 71 text
Current team
- 4 developers (a" fu" stack, one new)
- 1 Marketing
- 1 Customer support
- 1 Product manager
- Some fr!lance support (marketing + design)
Slide 72
Slide 72 text
One environment per developer
(serverless :))
Slide 73
Slide 73 text
No content
Slide 74
Slide 74 text
Good to start with
Slide 75
Slide 75 text
Testing
Slide 76
Slide 76 text
@slobodan_
Slide 77
Slide 77 text
@slobodan_
Slide 78
Slide 78 text
@slobodan_
Slide 79
Slide 79 text
@slobodan_
Slide 80
Slide 80 text
@slobodan_
Slide 81
Slide 81 text
@slobodan_
Slide 82
Slide 82 text
@slobodan_
Slide 83
Slide 83 text
@slobodan_
Slide 84
Slide 84 text
@slobodan_
Slide 85
Slide 85 text
Migrations
Slide 86
Slide 86 text
@slobodan_
Slide 87
Slide 87 text
@slobodan_
Slide 88
Slide 88 text
@slobodan_
Slide 89
Slide 89 text
@slobodan_
But, how does
this look like?
Slide 90
Slide 90 text
@slobodan_
describe('DynamoDB repository', () => {
describe('unit', () => { ... })
describe('integration', () => {
beforeAll(() => {
// Create test DB
})
afterAll(() => {
// Destroy test DB
})
// Tests
})
})
We have many other smaller challenges,
but we are happy with serverless!
Slide 102
Slide 102 text
@slobodan_
Slide 103
Slide 103 text
@slobodan_
Summary
Slide 104
Slide 104 text
@slobodan_
• Evolve your architecture with your product
• Pick a good architecture, it helps you to keep your migration and onboarding costs low
• Think about onboarding new team members
• Hexagonal architecture is a nice fit for serverless apps
• CQRS is also A nice fit for serverless apps and excellent fit for Vacation Tracker
• Test your integrations (and app in general)
• Testing is not enough, you'll need monitoring and error tracking