This is a beast of a question and I did not pace myself well.
Start by clarifying requirements and constraints, then propose a content-addressed storage design using filesystem APIs for metadata and data. Explain how deduplication, reference counting, and garbage collection work together to ensure isolation and scalability across nodes.
Pro tip: Emphasize that deduplication must be scoped per tenant to prevent cross-tenant information leakage, and discuss how to handle concurrent uploads and deletions safely with filesystem primitives like atomic renames and lock files.
Ask questions to confirm scale, consistency needs, and isolation requirements. Highlight that no database means metadata must be stored in files, and design must handle multi-node coordination.
Propose storing files by their hash (e.g., SHA-256) in a directory structure, with per-tenant namespaces to ensure isolation. Explain how uploads compute hash, check existence, and store only if new.
Use filesystem-based reference counts (e.g., a file per hash containing count and tenant references) to track deduplication. Ensure atomic updates using file locks or atomic operations.
On delete, decrement reference count; when zero, mark for deletion. Implement a garbage collector that scans for unreferenced files and removes them, handling race conditions with locking.
Discuss sharding by hash or tenant, using consistent hashing for node assignment. Explain how nodes coordinate via a shared filesystem or distributed protocol, and how to handle failures.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.