Squid restarts daemon every 10 minutes

This is a FreeBSD 9.1 installation which is mainly for Squid proxy server, I installed the default V2.7.stable9 package, I found that the Squid daemon automatically killed/reloaded every 5 to 10 minutes.

The server: HP DL380-G4 /2 Gb memory / 4* 146 GB HDD
FreeBSD version: 9.1
End-users of network: 250

BTW, the Squid daemon occupied 1 CPU resource:
Code:
last pid:  9034;  load averages:  0.99,  0.97,  0.92                                                                                            up 0+20:02:06  13:52:40
36 processes:  2 running, 34 sleeping
CPU: 10.3% user,  0.0% nice, 14.8% system,  0.2% interrupt, 74.7% idle
Mem: 46M Active, 1346M Inact, 252M Wired, 5800K Cache, 112M Buf, 345M Free
Swap: 3472M Total, 3472M Free

  PID USERNAME  THR PRI NICE   SIZE    RES STATE   C   TIME   WCPU COMMAND
 9027 squid       1 103    0 48176K 31768K CPU3    3   0:55 100.00% squid
 1172 root        1  20    0  9504K  1040K select  0   0:34  0.00% powerd
 1203 root        1  20    0 15332K  4660K select  0   0:02  0.00% httpd
 1093 root        1  20    0  9508K  1108K select  3   0:01  0.00% syslogd
 8450 gu28whu     1  20    0 15684K  4016K select  0   0:00  0.00% sshd
 1188 squid       1  41    0 11312K  2228K wait    1   0:00  0.00% squid
 1215 root        1  20    0  9536K  1172K nanslp  2   0:00  0.00% cron
 8447 root        1  20    0 15684K  4000K sbwait  0   0:00  0.00% sshd
 8464 gu28whu     1  20    0 10012K  1696K wait    3   0:00  0.00% su
 9028 squid       1  20    0  9624K  1252K kqread  1   0:00  0.00% dnsserver

Code:
<log file>:
(28) No space left on device
FATAL: Write failure -- check your disk space and cache.log
Squid Cache (Version 2.7.STABLE9): Terminated abnormally.
CPU Usage: 107.509 seconds = 44.723 user + 62.786 sys
Maximum Resident Size: 32616 KB
Page faults with physical i/o: 0
2013/07/31 15:35:23| Starting Squid Cache version 2.7.STABLE9 for i386-portbld-freebsd9.1...
2013/07/31 15:35:23| Process ID 9641
2013/07/31 15:35:23| With 11095 file descriptors available
2013/07/31 15:35:23| Using kqueue for the IO loop
2013/07/31 15:35:23| helperOpenServers: Starting 5 'dnsserver' processes
2013/07/31 15:35:23| logfileOpen: opening log /var/squid/logs/access.log
2013/07/31 15:35:23| Unlinkd pipe opened on FD 15
2013/07/31 15:35:23| Swap maxSize 4194304 + 524288 KB, estimated 362968 objects
2013/07/31 15:35:23| Target number of buckets: 18148
2013/07/31 15:35:23| Using 32768 Store buckets
2013/07/31 15:35:23| Max Mem  size: 524288 KB
2013/07/31 15:35:23| Max Swap size: 4194304 KB
2013/07/31 15:35:23| Store logging disabled
2013/07/31 15:35:23| Rebuilding storage in /var/squid/cache (DIRTY)
2013/07/31 15:35:23| Using Least Load store dir selection
2013/07/31 15:35:23| Current Directory is /var/squid/logs
2013/07/31 15:35:23| Loaded Icons.
2013/07/31 15:35:23| Accepting proxy HTTP connections at 0.0.0.0, port 8080, FD 16.
2013/07/31 15:35:23| Accepting ICP messages at 0.0.0.0, port 3130, FD 17.
2013/07/31 15:35:23| WCCP Disabled.
2013/07/31 15:35:23| Ready to serve requests.
2013/07/31 15:35:23| Store rebuilding is  0.0% complete
 
Any particular reason you're using version 2.7? I'd try it with the newer version instead. I'm currently running 3.3.8 from the www/squid33 port. Might be worth a try?

Also what's in the log files from /var/log/messages and /var/log/squid/cache.log? Anything to suggest why it's restarting?
 
I found that the problem is from file: /var/squid/cache/swap.state. The file is very big and runs out of disk space (40 GB+).

Why is the swap.state file so big? It is only the index of the cache.

Thanks for your idea, this V2.7 is the system default version. I will try to install the new version. And the problem is caused by the /var/squid/cache/swap.state file which is 40+ GB.

No hard-disk space from the RAID1 disk.
 
I guess you have a lot of objects in the in-memory and/or on-disk cache stores? I would imagine the swap.state size is directly proportional to this. Probably worth a clean out of all the cache stores?

Also when I was tuning my own Squid many years ago I vaguely remember reading about a configuration option called client_db which, unless you use the functionality, is recommended to switch off as it stores some data about every client connection in memory which takes up unneeded space. Might be worth investigating that. http://www.squid-cache.org/Doc/config/client_db/
 
May I know is there any idea how to keep swap.state file under control, such as max 1 GB? I added one weekly task to delete <swap.state> file and I hope the system keep stable from now on. Thanks!
 
Back
Top