[squid-users] squid in container aborted on low memory server

Amos Jeffries squid3 at treenet.co.nz
Mon Mar 4 05:44:38 UTC 2019


On 4/03/19 5:39 pm, George Xie wrote:
> hi all:
> 
> Squid version: 3.5.23-5+deb9u1
> Docker version 18.09.3, build 774a1f4
> Linux instance-4 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27)
> x86_64 GNU/Linux
> 
> I have the following squid config:
> 
> 
>     http_port 127.0.0.1:3128
>     cache deny all
>     access_log none
> 

What is it exactly that you think this is doing in regards to Squid
memory needs?


> 
> runs in a container with following Dockerfile:
> 
>     FROM debian:9
>     RUN apt update && \
>     apt install --yes squid
> 
> 
> the total memory of the host server is very low, only 592m, about 370m
> free memory.
> if I start squid in the container, squid will abort immediately. 
> 
> error messages in /var/log/squid/cache.log:
> 
> 
>     FATAL: xcalloc: Unable to allocate 1048576 blocks of 392 bytes!
> 
>     Squid Cache (Version 3.5.23): Terminated abnormally.
>     CPU Usage: 0.012 seconds = 0.004 user + 0.008 sys
>     Maximum Resident Size: 47168 KB
> 
> 
> error message captured with strace -f -e trace=memory:
> 
>     [pid   920] mmap(NULL, 411176960, PROT_READ|PROT_WRITE,
>     MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = -1 ENOMEM (Cannot allocate memory)
> 
> 
> it appears that squid (or glibc) tries to allocate 392m memory, which is
> larger than host free memory 370m.
> but I guess squid don't need that much memory, I have another running
> squid instance, which only uses < 200m memory.

No doubt it is configured to use less memory. For example by reducing
the default memory cache size.


> the oddest thing is if I run squid on the host (also Debian 9) directly,
> not in the container, squid could start and run as normal.
> 

Linux typically allows RAM over-allocation. Which works okay so long as
there is sufficient swap space and there is time between memory usage to
do the swap in/out process.

Amos


More information about the squid-users mailing list