Score:1

How to make two squid servers share the same disk cache?

is flag

I'm trying to setup squid proxy in a kubernetes environment as a caching server with 3 replicas. I wanted to know whether all three replicas can share the same disk storage, or I'll have to assign separate storage to each. Currently all three of them have this in the config:

cache_dir ufs /var/spool/squid 100 16 256

All three replica mount the same volume, so /var/spool/squid/ is shared among the three. This works in the sense that cached object takes space only once but the first request to each replica is always a miss. I am not sure if there are any downsides to configuring it like this, or if I should configure them to use separate storage(a Statefulset).

TL;DR: Can multiple squid instances share the same cache_dir?

stark avatar
mu flag
You should mount ro to avoid filesystem corruption. ufs is not a shareable filesystem.
Ardneliahs avatar
is flag
yes, but I want cache objects to be written to the disk. I see now that UFS is not shareable, can I make use of some other FS with squid to achieve this, or better configure each replica with its own UFS storage? @stark
stark avatar
mu flag
I guess you could mount on one and share with NFS to the others. That would avoid duplicate caching. No idea on performance, though.
SYN avatar
hk flag
SYN
I'm not sure squid allows for this: consider you could corrupt your whole cache if several squid processes try to edit the same file simultaneously. You could either use drbd/pacemaker ensuring a single squid instance would be started. Or just accept your squid replicas would not have the same cache. Which shouldn't be an issue anyway, beyond allocating storage twice
Ardneliahs avatar
is flag
yes, thats what I'll be going with. Thanks @SYN
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.