- 2075 Chaitra · 2+6 marks
Stateful vs stateless; NFS architecture
Short answer
Stateful servers keep client state, complicating recovery; stateless servers keep no state, needing idempotent operations. Sun NFS uses a VFS layer, NFS client/server, and mount service. The client sends RPCs with file handles; the stateless server maps handles to local files and returns results.
Compare stateful and stateless service. Describe the architecture and operation of SUN NFS with its services.
Stateful versus stateless service
| Point | Stateful service | Stateless service |
|---|---|---|
| Server memory | Keeps information about each client (open files, file pointers) | Keeps no client information |
| Request | Short; refers to a session or open file id | Longer; each carries file id, offset, count |
| Crash recovery | Complex; server must rebuild or clients must re-establish state | Simple; just restart |
| Client crash | Server must detect and clean orphaned state | No effect |
| Operations | Need not be idempotent | Must be idempotent (repeatable) |
| Performance | Fewer disk accesses, read-ahead is easier | More overhead per request |
| Locking | Easy to support | Needs a separate lock service |
| Example | AFS (callbacks), RFS | NFS (v2, v3) |
SUN NFS architecture and operation
SUN NFS (Network File System) is the most widely used distributed file service, developed by Sun Microsystems. It lets a client access remote files as if they were local, over an RPC-based protocol that is independent of the operating system, hardware and network.
Architecture
Client computer Server computer
+-----------------------------+ +-----------------------------+
| Application programs | | |
|-------- UNIX kernel --------| |-------- UNIX kernel --------|
| Virtual file system | | Virtual file system |
| | | | | | | |
| +----v-----+ +-----v-----+ | | +-----v-----+ +-----v----+ |
| | UNIX | | NFS | | | | NFS | | UNIX | |
| | file | | client | | | | server | | file | |
| | system | | | | | | | | system | |
| +----------+ +-----+-----+ | | +-----+-----+ +----------+ |
+---------------------|-------+ +-------|---------------------+
| |
+<---- NFS protocol --->+
(RPC over UDP/TCP)
- Virtual file system (VFS): a layer in the kernel that decides whether a request is for a local file or a remote file and passes it to the UNIX file system or to the NFS client. It keeps a v-node for each open file; the v-node holds an i-node reference for a local file or a file handle for a remote file.
- NFS client: translates VFS operations into RPC requests to the server.
- NFS server: receives requests, identifies the file by its file handle (file system id, i-node number, i-node generation number), and calls the local file system.
- Mount service: a client mounts a remote directory into its local file tree. The server lists the file systems it exports in /etc/exports, and the client records each mounted remote directory in its mount table.
- Automounter: mounts a remote directory on first use.
Operation
- The application issues a system call (for example read).
- The VFS finds that the file is remote and calls the NFS client.
- The NFS client sends an RPC (lookup, read, write, getattr, create, remove, mkdir, readdir...) over UDP/TCP using XDR encoding.
- The NFS server's VFS finds the local file by the file handle, runs the operation on the local file system and returns the result.
- The client caches the data (block cache) and attributes. Cache validity is checked by comparing timestamps; a cached entry is trusted for a freshness interval of about 3–30 seconds for files and 30–60 seconds for directories.
Features / properties
- Access and location transparency through mounting.
- Stateless server: each request carries all the information needed, so a crashed server restarts without recovery work; operations are idempotent.
- Heterogeneity: works with any OS that implements the protocol.
- Caching: read-ahead and delayed write for performance, with approximate (not strict one-copy) consistency.
- Security: the original version trusted the user id sent in the RPC; later versions use Kerberos.
- Limited replication and migration support.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- SUN NFS architecture and operation · Distributed System, chapter 2 · asked 3×
- DFS; stateless vs stateful services · Distributed System, chapter 2
- Stateful/stateless and DNS working · Distributed System, chapter 2
- Need of naming; Sun NFS · Distributed System, chapter 2
- Stub, skeleton and NFS architecture · Distributed System, chapter 2
- DFS requirements and file service architecture · Distributed System, chapter 2
- ISDN architecture, services and channels · Telecommunications, chapter 8 · asked 2×
- Web services architecture; SOAP and WSDL roles · Web Technology, chapter 8
- Basic ISDN services and architecture · Telecommunications, chapter 8
- Compare RISC and CISC architecture · Microprocessor, chapter 6 · asked 4×