April 24, 2024, 11:10:13 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Inner working of Squid  (Read 4425 times)

Offline rajesh.bahl

  • Linux Learner
  • ***
  • Posts: 86
Inner working of Squid
« on: May 02, 2008, 12:14:23 PM »

Our squid server seems to be working slow. We need to analyse the problem area.

1. We have verified the "input" bandwidth which is proper.
2. We need to check whether the client requests are getting catered from squid's cache or not ? For this we took observation from cache manager's "Cache Client List" which is reproduced below:-

Cache Clients:
Address: 192.168.0.3
Name: 192.168.0.3
Currently established connections: 0
    ICP Requests 0
    HTTP Requests 298
        TCP_HIT                   16   5%
        TCP_MISS                 202  68%
        TCP_REFRESH_HIT           13   4%
        TCP_IMS_HIT               59  20%
        TCP_NEGATIVE_HIT           8   3%

Address: 192.168.0.5
Name: 192.168.0.5
Currently established connections: 0
    ICP Requests 0
    HTTP Requests 156
        TCP_MISS                 129  83%
        TCP_REFRESH_HIT           10   6%
        TCP_REFRESH_MISS           6   4%
        TCP_CLIENT_REFRESH_M       2   1%
        TCP_IMS_HIT                9   6%

Address: 127.0.0.1
Name: 127.0.0.1
Currently established connections: 1
    ICP Requests 0
    HTTP Requests 11
        TCP_MISS                  11 100%

Address: 192.168.0.2
Name: 192.168.0.2
Currently established connections: 1
    ICP Requests 0
    HTTP Requests 349
        TCP_HIT                    6   2%
        TCP_MISS                 316  91%
        TCP_REFRESH_HIT           21   6%
        TCP_REFRESH_MISS           4   1%
        TCP_IMS_HIT                1   0%
        TCP_NEGATIVE_HIT           1   0%

Address: 192.168.0.9
Name: 192.168.0.9
Currently established connections: 0
    ICP Requests 0
    HTTP Requests 359
        TCP_MISS                 352  98%
        TCP_REFRESH_HIT            1   0%
        TCP_CLIENT_REFRESH_M       1   0%
        TCP_IMS_HIT                5   1%

Address: 192.168.0.8
Name: 192.168.0.8
Currently established connections: 0
    ICP Requests 0
    HTTP Requests 6
        TCP_MISS                   6 100%

TOTALS
ICP : 0 Queries, 0 Hits (  0%)
HTTP: 1179 Requests, 150 Hits ( 13%)

By seeing above, it seems that most of the requests are NOT getting catered from Cache ( TCP_Hits are very very low). How can we improve the scenario so that MAXIMUM number of client requests are served  through Cache only ?

Our Squid.conf file is as under:-

acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 8 MB
maximum_object_size 4096 KB
minimum_object_size 3 KB
store_avg_object_size 23 KB
cache_dir ufs /var/spool/squid 100 16 256
ftp_user squid@
redirect_program /usr/local/bin/squidGuard -c /usr/local/squidGuard/squidGuard.conf
redirect_children 8
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl Safe_ports port 80      # http
acl Safe_ports port 21      # ftp
acl Safe_ports port 443 563   # https, snews
acl Safe_ports port 70      # gopher
acl Safe_ports port 210      # wais
acl Safe_ports port 1025-65535   # unregistered ports
acl Safe_ports port 280      # http-mgmt
acl Safe_ports port 488      # gss-http
acl Safe_ports port 591      # filemaker
acl Safe_ports port 777      # multiling http
acl CONNECT method CONNECT
acl lan src 192.168.0.0/24
acl otherguys dstdomain  .xxx.com
acl otherguys dstdomain  .playboy.com
acl otherguys dstdomain  .adultfriendfinder.com
acl otherguys dstdomain  .gmail.com
http_access allow manager localhost
http_access deny manager
# Deny requests to unknown ports
http_access deny !Safe_ports
# Deny CONNECT to other than SSL ports
http_access deny CONNECT !SSL_ports
#acl our_networks src 192.168.1.0/24 192.168.2.0/24
#http_access allow our_networks
# And finally deny all other access to this proxy
http_access deny otherguys
http_access allow lan
http_access allow localhost
http_access deny all
cache_effective_user squid
cache_effective_group squid

acl FTP proto FTP
always_direct allow FTP
coredump_dir /var/spool/squid

Can someone help ?



regards
rajesh.bahl
 

Offline Ricky

  • LST CareTaker
  • Specially Skilled
  • *****
  • Posts: 2381
Re: Inner working of Squid
« Reply #1 on: May 02, 2008, 07:51:10 PM »
This is common complain from squid user. In order to maintain data authenticity, higher TCP_HIT are not really possible. However, you can work upon "refresh_pattern" as well as "    cache_replacement_policy" pattern directive to alter lifetime of cached object.

Also :
Code: [Select]
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 8 MB
maximum_object_size 4096 KB
minimum_object_size 3 KB
store_avg_object_size 23 KB
cache_dir ufs /var/spool/squid 100 16 256

You don't really need to deny cgi queries as server side are intelligent enough not let squid to cache those.. well.. if you want, you can keep it.

Increase your cache_mem 32 MB if your server allows.
Increase maximum_object_size to 20MB or 50MB
Remove minimum_object_size directive
increase cache_dir size to atleast 500 MB

You can also add following :
Code: [Select]
maximum_object_size_in_memory 100 KB
  ipcache_size 2048

You have to experiment with squid and see which works best for you. For   cache_replacement_policy and refresh_pattern, you can get information from default squid config file.