<div dir="ltr">Hello,<div><br></div><div>We need to configure a dedicated proxy server to provide caching of online video broadcasts in order to reduce the load on the uplink proxy.<br></div><div>Hundreds of users will access the same video-chunks simultaneously.</div><div><br></div><div>I developed a simple configuration for the test purposes (it is shown below).<br></div><div>The <b style="font-family:monospace">collapsed_forwarding</b> option is on.</div><div>I selected a couple of cacheable resources in the internet for testing:</div><div> - small size (~400 KB): <a href="https://ia800406.us.archive.org/13/items/romeo-y-julieta-texto-completo/Romeo%20y%20Julieta%20-%20William%20Shakespeare.pdf">https://ia800406.us.archive.org/13/items/romeo-y-julieta-texto-completo/Romeo%20y%20Julieta%20-%20William%20Shakespeare.pdf</a></div><div> - large (~8 MB): <a href="https://ia600601.us.archive.org/10/items/Linux-Journal-2015-01/Linux-Journal-2015-01.pdf">https://ia600601.us.archive.org/10/items/Linux-Journal-2015-01/Linux-Journal-2015-01.pdf</a></div><div>To test simultaneous connections I am forking curl using a simple script (it is also shown below).</div><div><br></div><div>When I run a test (500 curl threads to <a href="https://ia800406.us.archive.org/13/items/romeo-y-julieta-texto-completo/Romeo%20y%20Julieta%20-%20William%20Shakespeare.pdf">https://ia800406.us.archive.org/13/items/romeo-y-julieta-texto-completo/Romeo%20y%20Julieta%20-%20William%20Shakespeare.pdf</a>) I see lots of TCP_MISS/200 with FIRSTUP_PARENT/parent_proxy records in the logs.</div><div><br></div><div>A simple analysis shows a low percentage of cache hits:</div><div><font face="monospace">cat /var/log/squid.user/access.log| grep '2023-05-29 14' | grep pdf  | awk '{print $5" " $10}' | sort | uniq -c<br>     24 TCP_CF_MISS/200/- HIER_NONE/-<br>    457 TCP_MISS/200/200 FIRSTUP_PARENT/parent_proxy<br>     10 TCP_MISS/200/- HIER_NONE/-<br>      9 TCP_SWAPFAIL_MISS/200/200 FIRSTUP_PARENT/parent_proxy</font><br></div><div><br></div><div>So the Hit ratio is about (500-457-9)*100/500=6.8%</div><div><br></div><div>Almost the same situation we see when run 200 threads:</div><div><font face="monospace">cat /var/log/squid.user/access.log| grep '2023-05-29 15:45' | grep pdf  | awk '{print $5" " $10}' | sort | uniq -c<br>      4 TCP_CF_MISS/200/- HIER_NONE/-<br>    140 TCP_MISS/200/200 FIRSTUP_PARENT/parent_proxy<br>     40 TCP_MISS/200/- HIER_NONE/-<br>     16 TCP_SWAPFAIL_MISS/200/200 FIRSTUP_PARENT/parent_proxy</font><br></div><div><br></div><div>This time the Hit ratio is about (200-140-16)*100/500=21%<br></div><div><br></div><div>With 50 threads the Hit ratio is 90%:</div><div><font face="monospace">cat /var/log/squid.user/access.log| grep '2023-05-29 15:50' | grep pdf  | awk '{print $5" " $10}' | sort | uniq -c<br>     27 TCP_CF_MISS/200/- HIER_NONE/-<br>      1 TCP_MISS/200/200 FIRSTUP_PARENT/parent_proxy<br>     18 TCP_MISS/200/- HIER_NONE/-<br>      4 TCP_SWAPFAIL_MISS/200/200 FIRSTUP_PARENT/parent_proxy</font><br></div><div><br></div><div>I thought that it should always be near 99% - only the first request to an URL should be forwarded to the parent proxy and all subsequent requests should be served from the cache.<br></div><div><br></div><div>The situation is even worse with downloading a large file:<br></div><div>500 threads (0.4%):</div><div><font face="monospace">cat /var/log/squid.user/access.log| grep '2023-05-29 17:2' | grep pdf  | awk '{print $5" " $10}' | sort | uniq -c<br>     10 TCP_CF_MISS/200/200 FIRSTUP_PARENT/parent_proxy<br>      2 TCP_CF_MISS/200/- HIER_NONE/-<br>    488 TCP_MISS/200/200 FIRSTUP_PARENT/parent_proxy</font><br></div><div><br></div><div>200 threads (3%):</div><div><font face="monospace">cat /var/log/squid.user/access.log| grep '2023-05-29 17:3' | grep pdf  | awk '{print $5" " $10}' | sort | uniq -c<br>      9 TCP_CF_MISS/200/200 FIRSTUP_PARENT/parent_proxy<br>      6 TCP_CF_MISS/200/- HIER_NONE/-<br>    180 TCP_MISS/200/200 FIRSTUP_PARENT/parent_proxy<br>      5 TCP_SWAPFAIL_MISS/200/200 FIRSTUP_PARENT/parent_proxy</font><br></div><div><br></div><div>50 threads (98%):</div><div> <font face="monospace">cat /var/log/squid.user/access.log| grep '2023-05-29 17:36' | grep pdf  | awk '{print $5" " $10}' | sort | uniq -c<br>     25 TCP_CF_HIT/200/- HIER_NONE/-<br>     12 TCP_CF_MISS/200/- HIER_NONE/-<br>     12 TCP_HIT/200/- HIER_NONE/-<br>      1 TCP_MISS/200/200 FIRSTUP_PARENT/parent_proxy</font><br></div><div><br></div><div>Could you clarify if this behavior of my squid is a bug/misconfiguration, or if I'm running into server performance limitations (squid is running on a VM with 22 cores)?<br></div><div><br></div><div>Kind regards,</div><div>     Ankor</div><div><br></div><div><br></div><div><br></div><div><b>squid.conf:</b></div><div><font face="monospace">workers 21<br><br>sslcrtd_program /data/squid.user/usr/lib/squid/security_file_certgen -s /data/squid.user/var/lib/squid/ssl_db -M 20MB<br>sslcrtd_children 21<br><br>logformat extended-squid %{%Y-%m-%d %H:%M:%S}tl| %6tr %>a %Ss/%03>Hs/%<Hs %<st %rm %ru %un %Sh/%<A %mt %ea<br><br>logfile_rotate 0<br>access_log daemon:/var/log/squid.user/access.log logformat=extended-squid on-error=drop<br><br>cache_peer parent_proxy  parent 3128 0<br>never_direct allow all<br><br>cachemgr_passwd pass config<br><br>acl PURGE method PURGE<br>http_access allow PURGE<br><br></font></div><div><font face="monospace">http_access allow all<br><br>http_port 3131 ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=20MB tls-cert=/etc/squid.user/sslbump/bump.crt tls-key=/etc/squid.user/sslbump/bump.key<br>sslproxy_cert_error allow all<br><br>acl step1 at_step SslBump1<br>acl step2 at_step SslBump2<br>acl step3 at_step SslBump3<br><br>ssl_bump peek step1<br>ssl_bump bump step2<br>ssl_bump bump step3<br><br>cache_dir rock /data/squid.user/cache 20000 max-size=12000000<br>cache_swap_low 85<br>cache_swap_high 90<br><br><b>collapsed_forwarding on</b><br><br>pinger_enable off<br>max_filedesc 8192<br>shutdown_lifetime 5 seconds<br>netdb_filename none<br>log_icp_queries off<br>client_request_buffer_max_size 100 MB<br><br>via off<br>forwarded_for delete<br><br></font></div><div><font face="monospace">coredump_dir /data/squid.user/var/cache/squid<br></font></div><div><br></div><div><b>curl_forker.sh:</b><br></div><div><font face="monospace">#!/bin/sh<br>N=100<br>URL=<a href="https://ia600601.us.archive.org/10/items/Linux-Journal-2015-01/Linux-Journal-2015-01.pdf">https://ia600601.us.archive.org/10/items/Linux-Journal-2015-01/Linux-Journal-2015-01.pdf</a><br><br>if [[  -n $1 &&  $1 =~ help$  ]];<br>then<br>   echo "Usage: $0 [<cnt>] [<url>]"<br>   echo<br>   echo "Example: $0 10 <a href="https://ia600601.us.archive.org/10/items/Linux-Journal-2015-01/Linux-Journal-2015-01.pdf">https://ia600601.us.archive.org/10/items/Linux-Journal-2015-01/Linux-Journal-2015-01.pdf</a>";<br>   echo<br>   exit;<br>fi<br><br>while [[ $# -gt 0 ]]<br>do<br>  if [[ $1 =~ ^[0-9]+$ ]]<br>  then<br>     N=$1<br>  else<br>     URL=$1<br>  fi<br>  shift<br>done<br><br>echo $URL<br>echo $N threads<br><br>for i in `seq $N`<br>do<br>  nohup curl --tlsv1.2 -k   --proxy 0001vsg01:3131  -v $URL  >/dev/null  2>&1 &<br>done<br></font></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>