Out of scope
User count: 100 Million
DAU: 20 Million
QPS:
POST: api/upload
uploads data to signed url
POST: api/metaData
return meta data
GET: api/download/
downloads file
GET: api/
returns metadata
User
File
The way the application would work is that a file is kept on the client, the client. The client is responsible for regular checks against the server to check if metadata changed, like the updated time and version. if the updated time is different from that on the client. It either gets the latest from the server or uploads something to the update.
When uploading, we shall use something like AWS S3 which supports multipart uploading, this will give the client ability to upload the big files to s3. Another plus here is if the network is lost, the upload process doesn't have to begin all over again, it will pick up from where it left off as it knows which chunks were pushed up.
after this upload is done, the upload service shall change the metadata and add the new URL in the metadata. so when the client polls again to check for changes, the updated time would have changed and it will download this latest files on a different client
A part to focus on is the s3 upload, to make upload faster and get load off the server's bandwidth, we can have the client directly send this multi-part/chunked upload to s3. To do this, we submit the meta data first, then we ask for a resigned URL. we return this pre-signed URL to the client and have them push the file up that way. This takes load off the servers, allows the client to chunk and get progress response from the upload of large files. AFter upload is complete, it can update the FIle upload status to complete
Though we are dealing with files, I will opt of using CDNs as a cache for the following reasons, the files will be pushed to the nearest data center to the user and thus will be pretty close to the user. In the event there was an offline edit and we are back online, the extra complexity of invalidating this CDN is an unnecessary overhead at the moment
A simple master replica can be used for the ACID-compliant rdbms, we want the metadata very consistent. In the event this becomes a bottleneck, we can add more replicas or even shards. Due to the limitations of how many users an account can have, the probability of a hot shard will be low but we can monitor and come up with strategies to mitigate those
The polling to check for changes in the time stamp might be chatty. Maybe something like Pub/Sub service which queues the events of change and pushes them to a temp storage like Redis to let the users know which files changed. the user can use something like a WebSocket or SSE to get this notifications and then and only then, get the new file