---
title: "DFS; stateless vs stateful services"
subject: "Distributed System"
chapter: 2
key: "semester_7/distributed_system:dfs-stateless-stateful"
source: https://www.bctengineer.com/q/semester_7/distributed_system/dfs-stateless-stateful
site: BCT Engineering
---

# DFS; stateless vs stateful services

Distributed System · Chapter 2: Distributed Objects and File System

- Asked in: 2076 Asoj
- Video: [Operating System Important Topics | Comparison between Stateless and Stateful File System](https://www.youtube.com/watch?v=oSpuw6kC0pI) — Easy Engineering Classes
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/distributed_system/dfs-stateless-stateful
- Whole chapter: https://www.bctengineer.com/md/semester_7/distributed_system/chapter-2

## Question

Define Distributed file system. Point out the differences between stateless and stateful services.

## Short answer

A distributed file system provides transparent, shared access to files across a network. Stateful servers maintain client session state like open files and file pointers, using short requests but complex crash recovery; stateless servers store no client information, each request carries full context, making recovery simple but requiring idempotent operations.

## Answer

#### Distributed file system
A **distributed file system (DFS)** keeps files on one or more servers and gives clients on a network access to them as if they were local, with a common name space, transparency, sharing, security and consistency (for example NFS, AFS).

#### Stateless versus stateful services
| 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) |

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is the key difference between stateful and stateless file services?
   A. A stateful server keeps per-client information (open files, file pointers); a stateless one keeps none
   B. A stateless server keeps a table of open files; a stateful one does not
   C. A stateful server needs longer requests than a stateless one
   D. Both keep state but only stateless saves it on disk
   Answer: A. Stateless servers hold no client information, so every request must be self-contained. (Key point: Server memory)

2. Which statement about crash recovery is correct?
   A. A stateless server recovers by just restarting; a stateful server must rebuild state or clients must re-establish it
   B. A stateful server recovers by just restarting
   C. Both need complex recovery of open-file tables
   D. A stateless server must detect and clean orphaned state of crashed clients
   Answer: A. Nothing needs rebuilding in a stateless design, whereas stateful servers lose session tables. (Key point: Crash recovery)

3. Why must operations in a stateless service be idempotent?
   A. Because the server must remember each client's file pointer
   B. Requests may be retransmitted and repeating them must give the same effect
   C. Because requests are shorter and refer to a session id
   D. Because idempotent operations make locking easy
   Answer: B. With retransmission and no duplicate memory, repeated execution must be harmless. (Key point: Idempotent operations)

4. Which pairing is correct?
   A. Stateless: short requests using a session id, as in AFS
   B. Stateful: long requests carrying file id, offset and count, as in NFS
   C. Stateless: longer requests carrying file id, offset and count, as in NFS (v2, v3)
   D. Stateful: no need to track clients, as in NFS
   Answer: C. A stateless request must say which file, where and how much; NFS is the standard stateless example. (Key point: Request size and example)

## Related in Distributed System

- [Stateful vs stateless; NFS architecture](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Anfs-stateful-stateless) — Distributed System, chapter 2
- [Stateful/stateless and DNS working](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Astateful-dns-example) — Distributed System, chapter 2
- [DFS requirements and file service architecture](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Adfs-requirements-architecture) — Distributed System, chapter 2
- [Autonomous vs distributed system](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aautonomous-vs-distributed) — Distributed System, chapter 1
- [DFS architecture and storage sharing](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Adfs-architecture-sharing) — Distributed System, chapter 2, asked 4×
- [Importance of DFS; operations of SUNNFS](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Adfs-importance-sunnfs) — Distributed System, chapter 2

## Related in other subjects

- [Differences between DFS and BFS](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adfs-vs-bfs-differences) — Data Structure and Algorithm, chapter 10
- [File system layout; interface vs implementation](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afs-layout-interface-vs-implementation) — Operating System, chapter 5
- [File system layout; i-node vs linked list](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afs-layout-inode-vs-linked-list) — Operating System, chapter 5
- [File system layers; linked list vs index](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Afs-layers-linked-list-vs-index) — Operating System, chapter 5
