Answer by siddhantaws
S3 like storage
file size limit min to max - 100byte to 1TB
-What I will design end end to api to store
Durability number 99.11th 9
Deduplication
Rack level failure handling
Function requiment
UPLOAD,GET,DELETE
Deduplication
file versioning
avoid race condition during garbage coletion
Non functional requirement
Durability
Avalibility>consistenct 99.999 avalibility 5min
-p95 query time < 500ms
Avoid
Entity
bucket { id , name , visibility}
Objects { object_id , status, key , upload_by , }
Objects_chunks {id, object_id , chink_index , chunk_hash}
chunks { chunk_hash , refer_count , is_deleted, updated_at}
Back of envelope calculation
10B Object eeach 1MB
Total 10PB , 30PB
100MDAU , 2 Object each size 1MB
2TB per day +
800MB , 8GB Mbps
Rest API
POST /api/v1/{bucket}/{key} {
content_length : 3123132312
content_type "",
encoding :
{
"algo" : "sha-1",
"value" : "4234dfsdfsdf"
},
{
"algo" : "md5",
"value" : "4234dfsdfsdf"
}
"chunk_size" : 64MB
}
201 api/v1/upload/{upload_id} {
chunks : [ {"chunk_id" : 1 , "signed_url" : "ama" , st_range : 0,"ed_range" : "", expire_at} ]
}
302 api/v1/upload/{upload_id} {
}
201
api/v1/upload/{upload_id} {"chunk_idx" "1" , etag : }
api/v1/upload/{upload_id}/complete
GET api/v1/{upload}/
201 api/v1/{upload}/
{
"chunk" : 1 , "signed_url" : "", expire_at:""
}
Zookeeper
Monitor the health of storage node and give callback to monitoring service so that re-replication will happen
Replication will happen in priority order so that higher priority means lower im