createDirectory(name, parent)
deleteDirectory(path)
listDirectory(path)
open(name, parent, mode) -> File // mode = overwrite | append
write(file, content)
read(file, offset, length)
close(file)
delete(path)
// Table for directory hierarchy
// Table for file metadata
// In memory chunk information
Assume 200B per chunk, and each chunk is 64MB, total metadata size is 100PB / 64MB * 200 = 320GB which can fit a DB and can also into memory of one server.
API Gateway
API server
Metadata
ChunkManager
ChunkServer
MonitoringService
Directory management
Create file
Read file
ChunkManager
Write consistency
Instead of using a database to store metadata, we can also store it in memory. In this case we want to have write-ahead log, with replication and periodical checkpointing, so we can quickly reconstruct the state if the in-memory state goes down.
APIServer is stateless and can be horizontally scaled.
The Metadata is a relational database. We should enable high availability mode (read replicas, active-active or active-passive with strong consistency). We can improve reliability by partitioning the database by subtrees of the directory hierarchy.
ChunkManager has information about chunks in memory (e.g. Redis). We should have a standby.
Assume each ChunkServer can store 100TB of data. We need 100PB / 100TB = 1000 servers. ChunkServers might fail, and new servers are can be brought up. We can consider putting the ChunkServers on a consistent hash ring to minimize the amount of chunks that needs to be migrated.
Hotspot problem
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?