File Caching in Distributed File Systems
Last Updated :
19 Apr, 2023
File caching enhances I/O performance because previously read files are kept in the main memory. Because the files are available locally, the network transfer is zeroed when requests for these files are repeated. Performance improvement of the file system is based on the locality of the file access pattern. Caching also helps in reliability and scalability.
File caching is an important feature of distributed file systems that helps to improve performance by reducing network traffic and minimizing disk access. In a distributed file system, files are stored across multiple servers or nodes, and file caching involves temporarily storing frequently accessed files in memory or on local disks to reduce the need for network access or disk access.
Here are some ways file caching is implemented in distributed file systems:
Client-side caching: In this approach, the client machine stores a local copy of frequently accessed files. When the file is requested, the client checks if the local copy is up-to-date and, if so, uses it instead of requesting the file from the server. This reduces network traffic and improves performance by reducing the need for network access.
Server-side caching: In this approach, the server stores frequently accessed files in memory or on local disks to reduce the need for disk access. When a file is requested, the server checks if it is in the cache and, if so, returns it without accessing the disk. This approach can also reduce network traffic by reducing the need to transfer files over the network.
Distributed caching: In this approach, the file cache is distributed across multiple servers or nodes. When a file is requested, the system checks if it is in the cache and, if so, returns it from the nearest server. This approach reduces network traffic by minimizing the need for data to be transferred across the network.
Advantages of file caching in distributed file systems include:
- Improved performance: By reducing network traffic and minimizing disk access, file caching can significantly improve the performance of distributed file systems.
- Reduced latency: File caching can reduce latency by allowing files to be accessed more quickly without the need for network access or disk access.
- Better resource utilization: File caching allows frequently accessed files to be stored in memory or on local disks, reducing the need for network or disk access and improving resource utilization.
However, there are also some disadvantages to file caching in distributed file systems, including:
- Increased complexity: File caching can add complexity to distributed file systems, requiring additional software and hardware to manage and maintain the cache.
- Cache consistency issues: Keeping the cache up-to-date can be a challenge, and inconsistencies between the cache and the actual file system can occur.
- Increased memory usage: File caching requires additional memory resources to store frequently accessed files, which can lead to increased
- memory usage on client machines and servers.
Overall, file caching is an important feature of distributed file systems that can improve performance and reduce latency. However, it also introduces some complexity and requires careful management to ensure cache consistency and efficient resource utilization.
The majority of today's distributed file systems employ some form of caching. File caching schemes are determined by a number of criteria, including cached data granularity, cache size (large/ small/ fixed/ dynamic), replacement policy, cache location, modification propagation mechanisms, and cache validation.
Cache Location: The file might be kept in the disc or main memory of the client or the server in a client-server system with memory and disk.

Server's Disk: It is always the original location where the file is saved. There is enough space here in case that file is modified and becomes longer. Additionally, the file is visible to all clients.
Advantages: There are no consistency issues because each file has only one copy. When a client wants to read a file, two transfers are required: from the server's disk to the main memory, and from the client's main memory to the server's disk.
Disadvantages:
- It's possible that both of these transfers will take some time. One part of the transfer time can be avoided by caching the file in the server's main memory to boost performance.
- Because main memory is limited, an algorithm will be required to determine which files or parts of files should be maintained in the cache. This algorithm will be based on two factors: the cache unit and the replacement mechanism to apply when the cache is full.
Server's Main Memory: The question is whether to cache the complete file or only the disk blocks when the file is cached in the server's main memory. If the full file is cached, it can be stored in contiguous locations, and high-speed transmission results in a good performance. Disk block caching makes the cache and disc space more efficient.
Standard caching techniques are employed to overcome the latter issue. When compared to memory references, cache references are quite rare. The oldest block can be picked for eviction in LRU (Least Recently Used). The cache copy can be discarded if there is an up-to-date copy on the disk. The cache data can also be written to the disk. Clients can easily and transparently access a cached file in the server's main memory. The server can easily keep disks and main memory copies of the file consistent. Only one copy of the file exists in the system, according to the client.
Client's disk: The data can also be saved on the client's hard drive. Although network transfer is reduced, in the event of a cache hit, the disk must be accessed. Because the changed data will be available in the event of data loss or a crash, this technique improves reliability. The information can then be recovered from the client's hard drive.
Even if the client is disconnected from the server, the file can still be accessed. Because access to the disk may be handled locally, there is no need to contact the server, this enhances scalability and dependability.
Advantages:
- Reliability increased as data can be recovered in case of data loss.
- The client's disk has a significantly larger storage capacity than the client's primary memory. It is possible to cache more data, resulting in the highest cache-hit ratio. The majority of distributed file systems employ a file-level data transfer architecture, in which the entire file is cached.
- Scalability is increased as access to the disk can be handled locally.
Disadvantages:
- The sole drawback is that disc caching is incompatible with disk-less workstations. Every cache requires disk access, resulting in a considerable increase in the response time. It must be decided whether to cache in the server's main memory or on the client's disc.
- Although server caching eliminates the need for disk access, network transfer is still required. Caching data on the client-side is a solution for reducing network transfer time. Whether the system should use the client's main memory or the disk, depends on whether the system needs to save space or improve performance.
- The access is slow if the disk has more space. The main memory of the server may be able to provide a file faster than the client's disc. Caching can be done on the client's disc if the file size is very high. The below figure shows the simplest way, i.e., avoid caching.

Client's Main Memory: Once it is agreed that the files should be cached in the client's memory, caching can take place in the user process's address space, the kernel, or a cache manager as a user process.
The second alternative is to cache the files in the address space of each user process, as shown:

The system-call library is in charge of the cache. The files are opened, closed, read, and written during the process execution. The library saves the most frequently used files so that they can be re-used if necessary. The updated files are returned to the server once the operation has been completed. When individual processes open and close files regularly, this technique works well.
It's fine for database managers, but not for programmers working in circumstances where the files might not be accessed again.
The file can be cached in the kernel instead of the user's process address space, as shown. This technique, however, necessitates many systems calls to access the file for each cache hit.

A separate user-level cache manager can be used to cache the files. As a result, the kernel no longer has to maintain the file system code, and it becomes more isolated and flexible. The kernel can decide on the allocation of memory space for the program vs. cache on run time. The kernel can store some of the cached files in the disk if the cache manager runs in virtual memory, and the blocks are brought to the main memory on cache hit.

Advantages:
- This technique is more isolated and flexible (as the kernel no longer has to maintain the file system code)
- When individual processes open and close files regularly, the access time decreases. So, Gain in performance is maximum.
- Allows for diskless workstations.
- Contributes to the scalability and reliability of the system.
Disadvantages:
- A separate user-level cache manager is required.
- Client caching principles have no value with virtual memory, although the cache manager can lock some frequently requested pages.
Cache Consistency - Cache Update Policy:
When the cache is located on the client's node, numerous users can access the same data or file at the same time in a file system. If all caches contain the same most current data, they are considered to be consistent. It's possible that the data will become inconsistent if some users modify the file. The distributed system that uses a DFS must keep its data copies consistent.
Depending on when to propagate changes to the server and how to validate the authenticity of cache data, many consistency strategies are provided. Write-through, write-on-close, and centralized control are the three types.
When the cache is located on the client's node & one user writes data to cache, it must also be visible to the other users as well. The written policy determines that when the writing is performed.
There are four cache update policies:
- Write-Through: When a new user edits a cache entry in this method, it is immediately written to the server. Any procedure that requires a file from the server will now always receive the most up-to-date information. Consider the following scenario: the client process reads the file, caches it, and then exits the process. Another client modifies the same file and sends the change to the server a short time later.
If a process is started on the first machine with the cached copy of the file, it will obtain an outdated copy. To avoid this, compare the time of modification of both copies, the cached copy on the client's machine and the uploaded copy on the server, to validate the file with the server. - Delayed Write: To reduce continuous network traffic, write all updates to the server periodically or batch them together. It's known as 'delayed-write.' This method enhances performance by allowing for a single bulk write operation rather than several tiny writes. The temporary file is not stored on the file server in this case.
- Write on close: One step forward is to only write the file back to the server once it has been closed. 'Write on close' is the name of the algorithm. The second write overwrites the first if two cached files are written back to back. It's comparable to what happens when two processes read or write in their own address space and then write back to the server in a single CPU system.
- Centralized Control: For tracking purposes, the client sends information about the files it has just opened to the server, which then performs read, write, or both activities. Multiple processes may read from the same file, but once one process has opened the file for writing, all other processes will be denied access. After the server receives notification that the file has been closed, it updates its table, and only then can additional users access the file.
Cache Validation Scheme:
When a cache's data is modified, the modification propagation policy tells when the master copy of the file on the server node is updated. It provides no information about when the file data in other nodes' caches are updated. Data from a file may be stored in the caches of many nodes at the same time.
When another client alters the data corresponding to the cache item in the master copy of the file on the server, the client's cache entry becomes outdated. It's required to check whether the data cached at a client node matches the master copy. If this is not the case, the cached data must be invalidated and a new version of the data must be requested from the server.
To check cache data's Validity, 2 schemes are :
- Client-initiated Approach: The client connects to the server and verifies that the data it has in its cache is consistent with the master copy. The checking can be done at different times as-
- Verify before each access: As here the server must be called each time an access is made, this negates the actual purpose of caching data.
- Verifying periodically: Validation is done at a regular predetermined interval
- Verify the opening of the file: The cache entry is checked when a file is opened.
- Server-initiated Approach: When a client opens a file, it informs the file server of the purpose for opening the file - reading, writing, or both. It is then the duty of the file server to keep track of which client is working on which file and in which mode(s). When the server identifies any chance of inconsistency when the file is used by various clients, it reacts.
- A client notifies the server of the closure, as well as any changes made to the file when it closes a file. The server then updates its database to reflect which clients have which files open in which modes.
- The server can deny/queue the request, or disable caching by requesting that all clients who have the file open remove it from their caches whenever a new client requests to open a file that is already open and the server discovers any inconsistency which is there/may occur.
Similar Reads
Distributed Systems Tutorial A distributed system is a system of multiple nodes that are physically separated but linked together using the network. Each of these nodes includes a small amount of the distributed operating system software. Every node in this system communicates and shares resources with each other and handles pr
8 min read
Basics of Distributed System
What is a Distributed System?A distributed system is a collection of independent computers that appear to the users of the system as a single coherent system. These computers or nodes work together, communicate over a network, and coordinate their activities to achieve a common goal by sharing resources, data, and tasks.Table o
7 min read
Types of Transparency in Distributed SystemIn distributed systems, transparency plays a pivotal role in abstracting complexities and enhancing user experience by hiding system intricacies. This article explores various types of transparencyâranging from location and access to failure and securityâessential for seamless operation and efficien
6 min read
What is Scalable System in Distributed System?In distributed systems, a scalable system refers to the ability of a networked architecture to handle increasing amounts of work or expand to accommodate growth without compromising performance or reliability. Scalability ensures that as demand growsâwhether in terms of user load, data volume, or tr
10 min read
Difference between Hardware and MiddlewareHardware and Middleware are both parts of a Computer. Hardware is the combination of physical components in a computer system that perform various tasks such as input, output, processing, and many more. Middleware is the part of software that is the communication medium between application and opera
4 min read
Difference between Parallel Computing and Distributed ComputingIntroductionParallel Computing and Distributed Computing are two important models of computing that have important roles in todayâs high-performance computing. Both are designed to perform a large number of calculations breaking down the processes into several parallel tasks; however, they differ in
5 min read
Difference between Loosely Coupled and Tightly Coupled Multiprocessor SystemWhen it comes to multiprocessor system architecture, there is a very fine line between loosely coupled and tightly coupled systems, and this is why that difference is very important when choosing an architecture for a specific system. A multiprocessor system is a system in which there are two or mor
5 min read
Design Issues of Distributed SystemDistributed systems are used in many real-world applications today, ranging from social media platforms to cloud storage services. They provide the ability to scale up resources as needed, ensure data is available even when a computer fails, and allow users to access services from anywhere. However,
8 min read
Communication & RPC in Distributed Systems
Features of Good Message Passing in Distributed SystemMessage passing is the interaction of exchanging messages between at least two processors. The cycle which is sending the message to one more process is known as the sender and the process which is getting the message is known as the receiver. In a message-passing system, we can send the message by
3 min read
What is Message Buffering?Remote Procedure Call (RPC) is a communication technology that is used by one program to make a request to another program for utilizing its service on a network without even knowing the network's details. The inter-process communication in distributed systems is performed using Message Passing. It
6 min read
Group Communication in Distributed SystemsIn distributed systems, efficient group communication is crucial for coordinating activities among multiple entities. This article explores the challenges and solutions involved in facilitating reliable and ordered message delivery among members of a group spread across different nodes or networks.G
8 min read
What is Remote Procedural Call (RPC) Mechanism in Distributed System?A remote Procedure Call (RPC) is a protocol in distributed systems that allows a client to execute functions on a remote server as if they were local. RPC simplifies network communication by abstracting the complexities, making it easier to develop and integrate distributed applications efficiently.
9 min read
Stub Generation in Distributed SystemA stub is a piece of code that translates parameters sent between the client and server during a remote procedure call in distributed computing. An RPC's main purpose is to allow a local computer (client) to call procedures on another computer remotely (server) because the client and server utilize
3 min read
Server Management in Distributed SystemEffective server management in distributed systems is crucial for ensuring performance, reliability, and scalability. This article explores strategies and best practices for managing servers across diverse environments, focusing on configuration, monitoring, and maintenance to optimize the operation
12 min read
Difference Between RMI and DCOMIn this article, we will see differences between Remote Method Invocation(RMI) and Distributed Component Object Model(DCOM). Before getting into the differences, let us first understand what each of them actually means. RMI applications offer two separate programs, a server, and a client. There are
2 min read
Synchronization in Distributed System
Source & Process Management
What is Task Assignment Approach in Distributed System?A Distributed System is a Network of Machines that can exchange information with each other through Message-passing. It can be very useful as it helps in resource sharing. In this article, we will see the concept of the Task Assignment Approach in Distributed systems. Resource Management:One of the
6 min read
Difference Between Load Balancing and Load Sharing in Distributed SystemA distributed system is a computing environment in which different components are dispersed among several computers (or other computing devices) connected to a network. This article clarifies the distinctions between load balancing and load sharing in distributed systems, highlighting their respecti
4 min read
Process Migration in Distributed SystemProcess migration in distributed systems involves relocating a process from one node to another within a network. This technique optimizes resource use, balances load, and improves fault tolerance, enhancing overall system performance and reliability.Process Migration in Distributed SystemImportant
9 min read
Distributed Database SystemA distributed database is basically a database that is not limited to one system, it is spread over different sites, i.e, on multiple computers or over a network of computers. A distributed database system is located on various sites that don't share physical components. This may be required when a
5 min read
Multimedia DatabaseA Multimedia database is a collection of interrelated multimedia data that includes text, graphics (sketches, drawings), images, animations, video, audio etc and have vast amounts of multisource multimedia data. The framework that manages different types of multimedia data which can be stored, deliv
5 min read
Mechanism for Building Distributed File SystemBuilding a Distributed File System (DFS) involves intricate mechanisms to manage data across multiple networked nodes. This article explores key strategies for designing scalable, fault-tolerant systems that optimize performance and ensure data integrity in distributed computing environments.Mechani
8 min read
Distributed File System
What is DFS (Distributed File System)? A Distributed File System (DFS) is a file system that is distributed on multiple file servers or multiple locations. It allows programs to access or store isolated files as they do with the local ones, allowing programmers to access files from any network or computer. In this article, we will discus
8 min read
File Service Architecture in Distributed SystemFile service architecture in distributed systems manages and provides access to files across multiple servers or locations. It ensures efficient storage, retrieval, and sharing of files while maintaining consistency, availability, and reliability. By using techniques like replication, caching, and l
12 min read
File Models in Distributed SystemFile Models in Distributed Systems" explores how data organization and access methods impact efficiency across networked nodes. This article examines structured and unstructured models, their performance implications, and the importance of scalability and security in modern distributed architectures
6 min read
File Caching in Distributed File SystemsFile caching enhances I/O performance because previously read files are kept in the main memory. Because the files are available locally, the network transfer is zeroed when requests for these files are repeated. Performance improvement of the file system is based on the locality of the file access
12 min read
What is Replication in Distributed System?Replication in distributed systems involves creating duplicate copies of data or services across multiple nodes. This redundancy enhances system reliability, availability, and performance by ensuring continuous access to resources despite failures or increased demand.Replication in Distributed Syste
9 min read
What is Distributed Shared Memory and its Advantages?Distributed shared memory can be achieved via both software and hardware. Hardware examples include cache coherence circuits and network interface controllers. In contrast, software DSM systems implemented at the library or language level are not transparent and developers usually have to program th
4 min read
Consistency Model in Distributed SystemIt might be difficult to guarantee that all data copies in a distributed system stay consistent over several nodes. The guidelines for when and how data updates are displayed throughout the system are established by consistency models. Various approaches, including strict consistency or eventual con
6 min read
Distributed Algorithm
Advanced Distributed System
Flat & Nested Distributed TransactionsIntroduction : A transaction is a series of object operations that must be done in an ACID-compliant manner. Atomicity - The transaction is completed entirely or not at all.Consistency - It is a term that refers to the transition from one consistent state to another.Isolation - It is carried out sep
6 min read
Transaction Recovery in Distributed SystemIn distributed systems, ensuring the reliable recovery of transactions after failures is crucial. This article explores essential recovery techniques, including checkpointing, logging, and commit protocols, while addressing challenges in maintaining ACID properties and consistency across nodes to en
10 min read
Two Phase Commit Protocol (Distributed Transaction Management)Consider we are given with a set of grocery stores where the head of all store wants to query about the available sanitizers inventory at all stores in order to move inventory store to store to make balance over the quantity of sanitizers inventory at all stores. The task is performed by a single tr
5 min read
Scheduling and Load Balancing in Distributed SystemIn this article, we will go through the concept of scheduling and load balancing in distributed systems in detail. Scheduling in Distributed Systems:The techniques that are used for scheduling the processes in distributed systems are as follows: Task Assignment Approach: In the Task Assignment Appro
7 min read
Distributed System - Types of Distributed DeadlockA Deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource occupied by some other process. When this situation arises, it is known as Deadlock. DeadlockA Distributed System is a Network of Machines that can exchange info
4 min read
Difference between Uniform Memory Access (UMA) and Non-uniform Memory Access (NUMA)In computer architecture, and especially in Multiprocessors systems, memory access models play a critical role that determines performance, scalability, and generally, efficiency of the system. The two shared-memory models most frequently used are UMA and NUMA. This paper deals with these shared-mem
5 min read