SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
  • Block Storage
  • Distributed File Systems
  • Object Storage
  • Erasure Coding
  • Storage Tiers (Hot, Warm, Cold)
  • RAID
  • Compression and Deduplication
  • File Storage (NFS)
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Data and Storage/Storage Systems

File Storage (NFS)

A shared folder that many machines can mount, with the files and folders you already know.

โฑ 11 min readBeginnerHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

File storage gives you a shared folder over the network. Many machines can mount it and use it like a local disk, with the same files, folders and permissions they already know. NFS is the common protocol for this on Linux and Unix.

  • The server exports a folder. Clients mount it and then use normal file calls: open, read, write, rename.
  • Everyone sees the same files, so it is good for sharing between servers.
  • Every operation crosses the network, so latency matters, and the server can be a bottleneck or a single point of failure.

02Concept: What is it?

There are three main kinds of storage. Block storage is a raw disk for one machine. Object storage stores whole objects behind an HTTP API. File storage sits between them: it shows a tree of folders and files, and many machines can use it at the same time.

With NFS (Network File System), a server shares a folder, called an export. A client attaches it at a path such as /mnt/shared, called a mount. After that, programs on the client read and write files there with ordinary calls, and have no idea the bytes travel over a network. Windows networks use a similar protocol called SMB (also known as CIFS).

Many clients, one shared folder
๐Ÿ–ฅ๏ธWeb server 1/mnt/shared
๐Ÿ–ฅ๏ธWeb server 2/mnt/shared
๐Ÿ–ฅ๏ธWorker/mnt/shared
โ†’โ†“NFS over the network
๐Ÿ“‚File serverexports /data
โ†’โ†“local disks
๐Ÿ’ฝDisksblock storage
Each client mounts the same export, so they all see the same files.
๐Ÿง File, block and object in one line each
Block: a raw disk, for one machine. File: a shared folder, for many machines that need a real file system. Object: an unlimited bucket of whole files, accessed by key over HTTP.

03Real-Life Example

๐ŸตThe Shared Office Filing Cabinet
An office has one big filing cabinet in the corridor. Everyone uses the same drawers and the same labelled folders, so when one person files a contract, everyone else can find it right away. But it is a walk to the corridor for every folder, so fetching 100,000 one-page notes, one at a time, is painfully slow compared with fetching one thick file. And if the cabinet is locked, the whole office is stuck.
Office
File storage
The shared cabinet in the corridor
The NFS server and its export
Each desk's route to the cabinet
A mount on each client
Drawers and labelled folders
Directories and files
The walk to the corridor
A network round trip
Two people editing one page
File locking and cache consistency
The cabinet is locked
The server is down: a single point of failure
Who uses which kind of storage
๐Ÿ’ฝBlockone machine, fast, low latency
๐Ÿ“‚Filemany machines, shared folders
๐ŸชฃObjecthuge scale, HTTP, cheap
Pick by how the data is accessed, not just by how big it is.

04Why Do We Need It?

๐ŸคShare files between machines
Many servers see the same folder, so one saves a file and the others can read it.
๐Ÿ“Normal file semantics
Programs that expect paths, permissions, rename and locks work unchanged.
๐ŸงฑLegacy friendly
Old applications that need a file system can run on many machines without a rewrite.
๐Ÿ”Familiar permissions
Users, groups and access modes work as they do on a local disk.
๐Ÿ“ˆGrow storage separately
Add capacity on the file server without touching the clients.
๐Ÿ› ๏ธEasy to use
Mount once, then use the usual tools: ls, cp, a text editor.
When many machines need the same folder of files, with real file-system behaviour, shared file storage is the simplest answer.

05Where Do We Use It?

๐Ÿ Shared home directories
Users see the same home folder on every login machine.
๐Ÿ–ผ๏ธMedia for web servers
A content system whose uploads must be visible to every web server behind a load balancer.
๐ŸงชMachine learning and HPC
Many compute nodes read the same datasets and write checkpoints in a shared folder.
๐Ÿ“œLegacy applications
Software that needs a real file system, shared by several servers.
๐ŸŽฌMedia workflows
Teams edit large files from a common storage pool.
โ˜๏ธManaged file services
Cloud services such as Amazon EFS, Azure Files and Google Filestore run the file servers for you.

06Types / Parts / How It Works

How NFS is set up

Export and mount
๐Ÿ“‚Serverexport /data
โ†’โ†“mount
๐Ÿ–ฅ๏ธClient/mnt/shared looks local
The server shares a path. The client attaches it somewhere in its own tree.
An illustrative setup (options and names vary by system and version)
# on the server: /etc/exports
/data   10.0.0.0/24(rw,sync)

# on a client
mount -t nfs fileserver:/data /mnt/shared

Block vs file vs object storage

Block storageFile storage (NFS)Object storage
Looks likeA raw diskFolders and filesA bucket of keyed objects
Used byOne machine (usually)Many machines at onceAny client over HTTP
AccessBlock reads and writesPOSIX-style file callsPUT / GET of whole objects
LatencyLowestMedium: round trips for metadataHighest per request
ScalePer volumePer file server or clusterAlmost unlimited
Edit part of a fileYesYesNo: replace the whole object
Best forDatabases, boot disksShared folders, legacy appsPhotos, backups, static assets

Protocol versions and state

Older NFS versions were designed so the server kept little state about each client. Newer versions are stateful and add features such as better locking, security and parallel access. The details differ by version, so check which one your system uses.

What happens on a read

StepWhat the client doesWhy it costs time
LookupFind the file by walking the pathA network round trip for each folder level, unless cached
OpenAsk the server to open the fileOne more round trip
ReadFetch the bytesData transfer, possibly in several requests
CloseTell the server it is doneAnother round trip, and a point where changes are flushed
VisualizerWhich storage type fits, and why many small files hurtPick block, file or object for each workload card. Then raise the network round trip and compare copying one big file with copying 100,000 small files.
Part 1: which storage fits each workload?
Boot and data disk of one database server
One machine needs fast, low-latency reads and writes in small pieces, and it manages the disk layout itself.
Shared uploads folder for 5 web servers
Every web server must see the same files, in a normal folder path, as soon as one of them saves a file.
10 TB of user photos, served over HTTP
Millions of small and large files that are written once, read many times, and handed out to browsers all over the world.
Shared model checkpoints for training nodes
Many compute nodes read and write the same large files, using ordinary file paths in their training code.
Backup archive kept for years
Big files written once, rarely read, kept cheaply for a long time and never edited in place.
Static assets of a mobile app (images, JS, CSS)
Public files fetched by phones over HTTPS and cached close to users.
Pick a storage type for each workload below. You get feedback after each choice.
Part 2: one big file or many small files over a network mount?
Copying 1 GB from a network mount at 100 MB per second. The only difference is how the data is cut into files.
1 file of 1 GB
10.0 s
about 3 round trips + the transfer
100,000 files of 10 KB
10.2 min
about 3 round trips per file + the same transfer
Big file
10.0 s
1 file
Many small files
10.2 min
100,000 files
Slower by
61.0ร—
same bytes

Illustrative model, not a benchmark: every file is assumed to cost about 3 round trips (open, data request, close) one after another, and the link moves 100 MB per second. Real clients can overlap requests and cache metadata, but the lesson holds: on a network mount, the number of files matters as much as the number of bytes.

07How to Use It / Steps / Implementation

Using shared file storage well

  1. 1
    Check you really need a file system
    If you only store and fetch whole files, object storage is simpler and scales further. Choose file storage when you need folders, rename, locks or partial edits.
  2. 2
    Keep the file server close
    Put the server and clients in the same network zone. Every metadata call is a round trip, so distance hurts.
  3. 3
    Avoid huge numbers of small files in one folder
    Group data into fewer, larger files, or spread files over many folders.
  4. 4
    Use a managed or clustered service for important data
    A single NFS server is a single point of failure. Managed services and clusters add failover and replication.
  5. 5
    Understand caching and consistency
    Clients cache data and metadata for speed. Another machine may not see a change instantly. NFS usually promises that a file is up to date when it is opened after another client closed it.
  6. 6
    Be careful with locks
    Network file locks depend on the protocol version and the server. For coordination between machines, a lock service or a database is often safer.
  7. 7
    Set permissions and network access
    Limit which hosts may mount the export, use correct user and group mapping, and avoid exposing it to the open internet.
๐Ÿ’กLocal scratch plus shared results
For heavy jobs, copy input to a fast local disk, work there, and write only the final results back to the shared folder. This avoids thousands of network round trips.
โš ๏ธA network disk is not a local disk
Programs written for a local disk often assume fast metadata calls and instant visibility between processes. Over a network, both can be slower or look different, so test your application on the mount.

08Key Terms to Know

TermMeaning in easy words
NFSNetwork File System: a protocol for sharing a folder over a network, common on Linux and Unix
SMB / CIFSThe file-sharing protocol common in Windows networks
ExportA folder the server offers to share
MountAttaching a shared folder at a path on the client
POSIX semanticsThe usual Unix file behaviour: open, read, write, rename, permissions and locks
MetadataInformation about a file (name, size, owner, time), apart from its contents
File lockA way to say that one process is using a file, so others wait or fail
Client cacheA local copy of data or metadata kept by the client to save round trips
Close-to-open consistencyA promise that data written before a close is visible to a later open
File server / NASA machine or appliance whose job is to serve files over the network
Managed file serviceA cloud service that runs the file servers for you (EFS, Azure Files, Filestore)

09Pros, Cons and Trade-offs

โœ… Pros
  • Many machines share the same files
  • Real file-system behaviour for legacy apps
  • Simple to use: mount and go
  • Familiar permissions and tools
  • Managed versions remove most of the work
โš ๏ธ Cons
  • Every operation crosses the network, so latency matters
  • A single server is a bottleneck and a single point of failure
  • Many small files and huge folders are slow
  • Caching can show stale data to other clients
  • Does not scale to internet-size blobs like object storage

Trade-offs

ChoiceWe gainWe lose
File storage over blockSharing between machinesLatency and some speed
File storage over objectFolders, rename, locks and partial writesScale and low cost per gigabyte
Client caching onFewer round trips, faster readsOther clients may see old data for a moment
Client caching offFresh dataMuch slower
Single NFS serverSimple and cheapA single point of failure and a limit on scale
Managed file serviceFailover and growth handled for youCost and less control

10Common Problems and Mistakes

Common mistakes

  1. Storing millions of tiny files in one directory. Listing and opening them is slow over a network.
  2. Running a database on NFS without care. Latency, caching and locking differ from a local disk. Databases usually belong on block storage.
  3. Using NFS for internet-scale blobs. Object storage is cheaper and scales much further.
  4. One server for everything. If it fails, every client hangs.
  5. Trusting file locks across machines. They may not behave the way local locks do.
  6. Ignoring stale caches. Code that expects instant visibility between machines can break.
  7. Exposing the export too widely. Anyone who can reach the server may be able to mount it.

Things to watch

๐ŸงŠHung mounts
If the server stops answering, programs that touch the mount can freeze. Choose mount options and timeouts with care.
๐ŸŒSlow metadata
Listing big folders and many small opens dominate the time.
๐Ÿ”€Stale reads
A client may keep an old copy for a short time.
๐Ÿ”’Permissions mapping
User and group ids must match between client and server, or access will be wrong.

11Real-World Examples

โ˜๏ธAmazon EFS
A managed NFS service that many servers can mount at once.
๐Ÿ”ทAzure Files
Managed file shares that use SMB, and also NFS in some setups.
๐ŸŸฆGoogle Filestore
A managed file storage service for workloads that need a shared file system.
๐ŸขCorporate NAS
Offices and data centres run network-attached storage boxes for shared team folders.
๐Ÿง Training clusters
Many GPU nodes share datasets and checkpoints over a shared file system.
๐ŸŒWeb farms
Several web servers mount the same folder for user uploads and shared assets.
๐Ÿ“Note
Product features, limits and protocol versions change over time. Check the current documentation of the service you plan to use.
Mini case: three web servers and one uploads folder
๐Ÿ™‹User uploadsgoes to any server
โ†’โ†“load balancer
๐Ÿ–ฅ๏ธWeb 1
๐Ÿ–ฅ๏ธWeb 2
๐Ÿ–ฅ๏ธWeb 3
โ†’โ†“mount
๐Ÿ“‚Managed file share/uploads
Latency of a local diskillustrative
Latency of a network mountillustrative
Local Over the network
Each server mounts the same share, so an upload on one is visible to all.

12Related Topics to Read Next

Block Storageโ†’

The raw disks that file servers are built on, and the best fit for databases.

Object Storageโ†’

The alternative for huge, mostly read-only files served over HTTP.

Distributed File Systemsโ†’

Scale-out file systems built for very large clusters.

Single Point of Failure (SPOF)โ†’

What a lone NFS server is, unless you add failover.

Stateless vs Statefulโ†’

A stateless web tier is easier to run when shared state sits on a shared store.

Latency vs Throughput vs Bandwidthโ†’

Round trips decide how fast file operations feel over a network.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • โœ”What: a shared folder over the network. Server exports, client mounts.
  • โœ”Protocols: NFS (Unix and Linux), SMB (Windows).
  • โœ”Fits: shared home folders, web uploads, ML data, legacy apps.
  • โœ”Cost: every operation is a round trip. Many small files are slow.
  • โœ”Risk: one server is a bottleneck and a SPOF. Use managed or clustered.
  • โœ”Consistency: clients cache. Fresh on open after close, but not instantly everywhere.
  • โœ”Compare: block = one machine, file = many machines + folders, object = huge scale + HTTP.
  • โœ”One line: โ€œA shared cabinet in the corridor: handy for everyone, slow for tiny trips, bad if it is locked.โ€
โ† Previous
Compression and Deduplication
Next โ†’
Client-Server