1

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?

Ardneliahs
  • 21
  • 6
  • You should mount ro to avoid filesystem corruption. ufs is not a shareable filesystem. – stark Nov 03 '22 at 12:10
  • 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 – Ardneliahs Nov 03 '22 at 12:20
  • I guess you could mount on one and share with NFS to the others. That would avoid duplicate caching. No idea on performance, though. – stark Nov 03 '22 at 12:50
  • 1
    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 – SYN Nov 06 '22 at 09:42
  • yes, thats what I'll be going with. Thanks @SYN – Ardneliahs Nov 11 '22 at 04:24

0 Answers0