POST /files/upload?uploadType=simple - used for simple uploads when the file size is small
uploadType=resumable - used for large resumable files
body: {file:File, fileDetails:JSON, workspaceId:string}
POST /files/resume/uploadId/{uploadId} - used for resuming an upload
POST /download/file/{fileId} - used for downloading a file content
GET /files/{fileId} - used for fetching the data of a file including its upload status
upload flow:
to achieve consistency, data from master db and slave replicas must be kept in sync, also each db write will invalidate the cache. a cdn will be used as cloud storage and it will store the file contents, metadata db wont have the contents, only details and metadata and file versions.
flow for resuming a download/upload - we make a call to fetch the url from server side and then we check the file status, if it is still uploading or downloading in progress, then we can resume it by checking the missing blocks and continuing to upload/ download the missing ones.
on system failures:
if a load balancer fails, another available one will take its place;
block server failure - other server will pick it up
cloud storage: s3 failure, a new s3 instance will pick it up, either from same region, or if a region is down then from a near region;
api server - they are stateless so a new api server instance can pick it up
metadata cache failure - metadata cache is replicated multiple times so a replica can pick it up
metadata db failure - if master is down then a slave will be prompoted, if a slave is down then a new instance will take its place
notification service failure - a new instance will start picking up from the ongoing requests
offline backup queue failure - if one queue fails then subscribers might need to resubscribe to a new one
files are split into blocks of 4mb on upload and then each block gets a hash value, is then encrypted and stored in cloud storage. on editing a file, we compute the hash values and check against the stored ones, if we find different values then we update only those blocks and write in cloud the updates. cold storage will store the least used files and file versions so it wont occupy too much memory in cloud storage (which needs to be as fast as possible for retrieval/writes)
flow for resuming a download/upload - we make a call to fetch the url from server side and then we check the file status, if it is still uploading or downloading in progress, then we can resume it by checking the missing blocks and continuing to upload/ download the missing ones.
on system failures:
if a load balancer fails, another available one will take its place;
block server failure - other server will pick it up
cloud storage: s3 failure, a new s3 instance will pick it up, either from same region, or if a region is down then from a near region;
api server - they are stateless so a new api server instance can pick it up
metadata cache failure - metadata cache is replicated multiple times so a replica can pick it up
metadata db failure - if master is down then a slave will be prompoted, if a slave is down then a new instance will take its place
notification service failure - a new instance will start picking up from the ongoing requests
offline backup queue failure - if one queue fails then subscribers might need to resubscribe to a new one