Total user : 100 Million
Lets assume user a user data is : 200Bytes this table is only for user meta data
User space : 100*200 -->. 10Billion --> 10 GB
Storage size for a day :
10Million * 5*1000*1000 -->. 50000Billion Bytes --> 50TB/Day
TPS : 10Million /10000-> ~10TPS
For data storage
For 5 years : 50*5*365 TB --> 400*250 --> ~100PB
Lets assume we are having master slave replica with 3 slave
So total size : 300PB
Post : /v1/upload --> data as bytes
Response will be {documentId:"xxxfstw7623672883"}
Get : /v1/docuemnts?userId=''
Response --> {
docId,
created at,
lastUpdated,
LastUpdated by
}
Put : /v1/update/{documentId} --> body will content
Post : /v1/share/{doumentId} Body {List:{usrId}}
User table ->{
userId: string(PK)
email : string(UK)
createdAt:
updatedAt
}
userDocumentMeta ->{
docId : PK
contentAddress: --> Location of data
createdby : userId; --> Index
createdAt :
}
DocumentVersion{
id : PK
docId: FK parent table --> userDocumentMeta
version: String
comment : String
created at : timestamp
updated by : userId
documentAddress: blockId
}
As update is allowed so recommended is to use block storage
ContetTable {
id PK
blockId : FK parent will be DocumentVersion
content: String
offset:
nextBlock:
}
Foreign keys :
userDocumentMeta : createdby column
userDocumentMeta --> Index will be userId
Component ->
Client.
LB
DropBoxServer
DB
BroadCastService : Queue based notification(Client can connect and update latest meta data )
Client :
Server
How it will be scaled for 1Million user :
As we have DropBoxServer services are running behind LB they can be horizontally scale on demand basis.
To scale our data base we can user sharding on basis of userId and can user muli master model.
Client APK/Client side:
BackEnd:
Upload/update flow
Download flow:
How client maintained the data locally?
How updated data stored in backend?
How data will be synced from one client to another client?
How delta will be stored at backend?
How client maintained the data locally?
How updated data stored in backend?
How data will be synced from one client to another client?
How delta will be stored at backend?
DB : For user and meta storage : RelationDB --> Postgres/Mysql
For data content storage: NoSQL --> DynamoDB/Cassendar (Chooses because of availability’s )
Trade Offs
Client pull vs push data sync to backend.
What will happened if client not able to upload the changes?(or client is offline)
bottlenecks:
Data consistency : As data is updating async, we can pick strong consistency
Notifying the changes to all the client. For small scale this approach will works.