- Unix Commands Reference
- Unix Commands - Home
distcache Command in Linux
The distcache is a distributed session cache tool used in Linux environments. It provides a protocol and a set of tools to allow applications and machines to share session states through the network. This system is particularly useful for SSL/TLS session caching, allowing servers to share session state to improve load-balancing.
Table of Contents
Here is a comprehensive guide to the options available with the distcache command −
- Essential Tools for distcache in Linux
- Overview of distcache APIs in Linux
- Implementing distcache in Linux
Note − The distcache project has been deprecated and is no longer available in the default repositories of many Linux distributions. It was not actively maintained, which led to its discontinuation.
For those interested in implementing distributed caching, the source files are still available on SourceForge. However, please be aware that distcache may not support ARM-based systems.
Essential Tools for distcache in Linux
The distcache is implemented using various tools. All tools are listed in the following table −
Tools | Description |
---|---|
dc_server | It runs a cache server that listens on a configurable network address (Acts as the primary server for handling cache processes). |
dc_client | It runs a local proxy (Interfaces with dc_server to optimize network usage). |
dc_test | It is used to test and measure the performance of the distcache server and client installation (Sends many requests to a specified network simultaneously using distcache protocol). |
dc_snoop | It is a transparent proxy tool used to monitor cache operations between endpoints, from the application to the dc_client, and from the dc_client to the dc_server. |
Overview of distcache APIs in Linux
The distcache also offers various APIs to implement the protocol. A list of APIs is given below −
- libnal
- Libdistcache
- libdistcacheserver
libnal
The Network Abstraction Library (libnal) provides an abstraction for distcache libraries and tools. It comes with various objects −
Objects | Description |
---|---|
NAL_ADDRESS | Manages address abstraction; identifies whether the address is valid for listening, connecting, or both. |
NAL_CONNECTION | It encapsulates the network connection for sending and receiving binary data. |
NAL_LISTENER | It encapsulates listening sockets to accept incoming connection requests and create NAL_CONNECTION objects for each connection. |
NAL_SELECTOR | It handles non-blocking I/O by monitoring NAL_LISTENER and NAL_CONNECTION objects. |
NAL_BUFFER | It implements the FIFO buffer used for managing data read from or written to a NAL_CONNECTION. |
libdistcache
The libdistcache API provides two headers to interact with the distcache system. These headers are listed in the following table −
APIs | Description |
---|---|
distcache/dc_plug.h | It provides a low-level interface with the distcache protocol. It supports non-blocking communication. |
distcache/dc_client.h | It provides a higher-level interface with the distcache protocol that simplifies interactions. It supports blocking operations, meaning functions like add, get, and remove will only return after completing the full request/response cycle. |
libdistcacheserver
This API is used for session caching using the distcache protocol. It is useful for environments where sessions are distributed across multiple servers.
Implementing distcache in Linux
In Linux, the distcache protocol is implemented using its tools, such as dc_server, dc_client, and others.
Running a Cache Server
To run a cache server that listens to an IP address for incoming connections, use −
dc_server -listen [ip_address]:[port]
For example, to listen to the localhost on port 12533, use −
dc_server -listen 127.0.0.1:12533
Connecting with Cache Server
To connect with the cache server, use the dc_client tool.
dc_client -connect [ip_address]:[port]
For example, to connect to a cache server at 127.0.0.1:12533, use −
dc_client -connect 127.0.0.1:12533
Testing a Cache Server
To benchmark the distcache server, the dc_test tool is used with the -server option −
dc_test -server 127.0.0.1:12533 -requests 2000
The -requests option sends a barrage of requests to test the cache server capability.
Monitoring the Cache Operation
To monitor the cache operation between client and server, the dc_snoop tool is used.
dc_snoop -listen 127.0.0.1:11200 -connect 127.0.0.1:12533
The dc_snoop listens for connections from clients and forwards them to the server at 127.0.0.1:12533.
Conclusion
The distcache is a distributed caching tool that provides a protocol to share session states between applications and machines. It comes with various tools to implement the distcache protocol. It also offers APIs and libraries to integrate the distcache protocol in different applications and systems. It is deprecated due to not being maintained and updated. However, its files are still available on SourceForge and can be used to implement it on x86 systems.
In this tutorial, we explain the distcache distributed caching system, its tools, APIs, and usage in Linux through various examples.