1. 111 Steps to Building a
Multi-tenanted SaaS in
Node.js
Eoin Shanaghy
Edappy
eoins
eoinsha
1
2. Edappy started with a single-tenanted internal
system, delivering University-level courses
Node.js - Seneca - Express - MongoDB
Microservices
Dockerised EC2
The job: Make the platform a multi-tenanted SaaS
4. “This should be easy”
4
a.edappy.com b.edappy.com
c.edappy.com d.edappy.com
5. We started to think about Tenant Provisioning.
“How often?”
“How big?”
“How does it relate to the business model?”
“How will we…monitor it, maintain it or deploy it?”
5
6. We will have many small tenants. Some
will be just evaluating, at least at first.
They will be spread internationally and
many will use a free tier.
A few will be large, enterprise tenants.
They will take longer to publish their
content but will have many thousands of
students and many, large courses.
6
7. Don’t just think production.
How do I run a multi-tenanted
SaaS in development?
What will my tests look like?
How many processes, containers
and VMs will I need to run?
7
9. No new hardware.
Before adding any containers or instances,
maximise every bit of existing
infrastructure.
Faster start.
Lower maintenance.
More cost effective.
9
24. Tenant Stores
There are hundreds of actors
Each actor has 0..* store operations
How do you avoid explicitly setting the
zone for every operation?
24
25. Write another Seneca plugin
Use seneca.wrap
Intercept all entity actions
Look up the zone/context if not already set
Provision the DB, if not already done
Configure the store plugin
Set the zone and call seneca.prior
25
30. Tenant Provisioning
Register a tenant record
Create external resources (bucket)
Configure database
Approximately $0 cost
30
31. Integration Testing
At least one instance of each service
At least two tenants
Clean database per suite
Docker Compose
Each test begins outside the app boundary (SuperTest)
Seneca test actions to perform setup/teardown
31
32. Oversight
We use ELK for aggregated logs across containers and
services
Log and index tenant ID
APIs
Actions
Debugging
32
33. Scaling
Up to a point, adding instances, containers is okay
Large, high value tenants warrant dedicated resources
Limit tenant-specific resources per app instance (DB
connections, etc.)
Explicit/Manual, Mesos, Kubernetes
33