Speaker: Julio Viera, VP Engineering - Backend as a Service, Fuze
Level: 300 (Advanced)
Track: Application Architecture
At Fuze, we are going through the process of re-architecting our backends and we decided to use a microservices approach. Microservice architectures face common challenges like geo-distribution of data, retention periods, and security rules. We found that MongoDB with zone sharding enabled us to address these concerns effectively. We created a service called The Floppy, which is a RESTful Object Storage that automatically scales and distributes the data around the world. The Floppy also supports real-time queries via WebSockets and advanced security rules using expressions that are evaluated in real time.
What You Will Learn:
- How to deploy MongoDB globally with Zone Sharding (also known as Tag Aware Sharding).
- How to abstract application logic from the Zone Sharding architecture.
- How to implement a publish and subscribe framework that evaluates document writes and triggers events to applications listening for changes.
5. The requirements
Document and binaries
Scalable / High available
Support retention
Authentication
Backup
Data change notifications
Accessible from clients
7. Stats
5 teams in the company using Floppy
Chat attachments, retention info and sessions
User settings for some deskphones
Internal beta:
Meetings metadata storage/sync
Next iteration of chat and presence
2.6 MM operations per day: ~30/sec 1000/sec peak
45 Collections
50 MM Documents
9. Why Mongo
+5 years using it
Document storage
Developer friendly
Designed for high availability and scalability
Natively supports sharding and zone sharding
Natively supports TTL indexes
10. Why RESTful
Abstraction layer
Rate limit
Control Query complexity via Query Language
Control the operations done in the DB
Accessed over the internet - clients can use it as a DB in the cloud
We can reuse our current authentication system
13. Stack
Java
RestEASY / Netty
MongoDB Java Driver
Oplog consumer based on two popular open source libraries
AWS
EC2 for MongoDB
ElasticBeanstalk & Docker for the App
17. Schema - Url to Floppy structures
Storage: chat
Collection: conversations
Sub-collection: messages
Documents: conv or message
/users/123/chat/conversations/X/messages/Y
18. Schema - Url to Mongo structures
Storage: storage_chat
(maybe to db in the future)
Collection: chat_conversations
Sub-collection: chat_conversations_messages
Documents: mongo documents
(messages have a parent id)
/users/123/chat/conversations/X/messages/Y
23. Our Sharding philosophy
We always design with sharding in mind
We always start with sharded deployments (1 shard)
We always have at least 3 replica set members per shard
24. Goals
User's data should live in a single chunk until it is outgrown
Tenant data should live in a single chunk until it is outgrown
Sharding complexity must be hidden from the REST interface
44. Sharding Example Location: 0
Tenant: "CIA"
User: "jsmith"
_id: 1
_id: 2
_id: 3 _id: 4
_id: 5 _id: 6
_id: 7
User's data should live in a single chunk until
it is outgrown