diskd (short for disk daemons) is similar to aufs in that disk I/Os are executed by external
processes. Unlike aufs, however, diskd doesn't use threads. Instead, inter-process
communication occurs via message queues and shared memory.
Message queues are a standard feature of modern Unix operating systems. They were invented
many years ago in AT&T's Unix System V, Release 1. The messages passed between processes
on these queues are relatively small: 32-40 bytes. Each diskd process uses one queue for
receiving requests from Squid and another queue for transmitting results back.
Squid creates one diskd process for each cache_dir. This is different from aufs, which uses a
large pool of threads for all cache_dirs
Squid waits for the diskd processes to catch up if one of the queues exceeds a certain
threshold. The default value is 64 outstanding messages. If a diskd process gets this far behind,
Squid "sleeps" a small amount of time and waits for it to complete some of the pending
operations. This essentially puts Squid into a blocking I/O mode. It also makes more CPU time
available to the diskd processes. You can configure this threshold by specifying a value for the
Q2 parameter on a cache_dir line:
cache_dir diskd /cache0 7000 16 256 Q2=50
Squid stops asking the diskd process to open files if the number of outstanding
operations reaches another threshold. Here, the default value is 72 messages. If Squid would
like to open a disk file for reading or writing, but the selected cache_dir has too many pending
operations, the open request fails internally. When trying to open a file for reading, this causes
a cache miss instead of a cache hit. When opening files for writing, it prevents Squid from
storing a cachable response. In both cases the user still receives a valid response. The only real
effect is that Squid's hit ratio decreases. This threshold is configurable with the Q1 parameter:
cache_dir diskd /cache0 7000 16 256 Q1=60 Q2=50
Note that in some versions of Squid, the Q1 and Q2 parameters are mixed-up in the default
configuration file. For optimal performance, Q1 should be greater than Q2.