Some summary of squid use

Source: Internet
Author: User
Tags memory usage server memory
Some summary of squid use

1.cache_dir

In the Linux environment with AUFS type of cache_dir more stable, faster. Cache_dir file system If you use the Noatime option to mount, you can avoid

The operation of access time is frequently updated when accessing cache files.

The ratio between general cache capacity and accelerated content is appropriate at 1:10 to 1:20.

Cache_dir Aufs/var/spool/squid 10240 64 64
This is a typical Web site Web caching server Cache_dir configuration that accelerates content from 100GB to 200GB

Cache_dir Aufs/var/spool/squid 1024 16 64
This is a typical office transparent agent Cache_dir configuration, accelerated 10GB to 20GB content


2.cache_mem

Many articles say cache_mem to be set to half the amount of physical memory, such as physical memory 2GB Cache_mem to set to 1GB. But after the actual use of the test, which often

Is the culprit that causes server memory overload. "Squid:the Definitive Guide" about Cache_mem said: "This directive doesn ' t

Entirely control the size of the Squid process. In actual use, memory usage tends to exceed cache_mem limits, that is to say,

The amount of squid consumed does not seem to be controlled by this parameter. Therefore, this parameter does not need to set too large, the right amount on the line, my settings are:

Server:
Cache_mem MB

Lan:
Cache_mem MB

In addition, setting a smaller maximum_object_size_in_memory value helps to effectively control squid excess memory, for example:
Maximum_object_size 12288 KB
Maximum_object_size_in_memory KB

Memory_pools off is also a good setting

On the other, personally feel squid this software design of the failure of the place is memory management this piece ...


3. Transparent Agent

The firewall is set up for port blocking, and then this setting enables transparent proxies:

Httpd_accel_port 80 (0: Speed any port)
Httpd_accel_host Virtual
Httpd_accel_uses_host_header on
Httpd_accel_with_proxy on


This is to make two modes of work: Agent mode and Acceleration mode, while working. To turn off proxy mode, simply set the httpd_accel_with_proxy to OFF


4.http_port

Http_port can be set repeatedly to allow squid to listen on multiple ports

Http_port 80
Http_port 3128
Http_port localhost:8080


5. Access control

ACL it_nets src 192.168.0.0/19 (restricted access IP)
ACL Over_conn_limit maxconn 20 (limited number of connections)
ACL illegal_access url_regex-i what_ever_you_want (Restrict access to content)

Http_access Deny Over_conn_limit
Http_access Deny Illegal_access
Http_access Allow It_nets
Http_access Deny All


Update cycle of 6.cache files

Refresh_pattern ^/$ 0 66% reload-into-ims
Refresh_pattern ^.+/(<^.>*) $0 66% 720 reload-into-ims
(home, updated more frequently, cache update cycle shorter)

Refresh_pattern-i/. (HTM|HTML|TXT|JS) $0 66% 1440 Reload-into-ims
(General page, update less frequently, cache update cycle a bit longer)

Refresh_pattern-i/. (bmp|gif|jpg|png|swf) $0 66% 10080 reload-into-ims
(Picture, Flash, update the most infrequent, cache update cycle longest)

Refresh_pattern. 0 66% 10080 Reload-into-ims
(default, longer)


Reload-into-ims

When set, this option makes Squid transform a request with a No-cache directive into a validation

(if-modified-since) Request. In other words, Squid adds a if-modified-since header to the request

Before forwarding it on. This is only works for objects that have a last-modified timestamp.

The outbound request retains the No-cache directive, so that it reaches the origin server.

The meaning is: only on the source server file changes in the actual situation to update the cache content.

Tip: Ctrl+f5 can force browsers and squid to refresh its cache.

Digression: Content Management System (CMS) in the Update release page, should have a communication mechanism with the cache server, notify cache refresh updated content


7. Miscellaneous

Negative_ttl 0 Minutes

Pipeline_prefetch on (helps with the speed at which the boost Squid handles client requests)

Forwarded_for on

Dns_nameservers 202.96.128.86 202.96.128.166


8.squid+apache

Squid in the Apache server can effectively reduce the number of Apache derivative processes, thereby reducing memory consumption.

Using Squid's access control function, it can realize the function of content filtering, connection limit and so on that Apache power can't.

Squid I/O-driven request processing mode, more efficient implementation of static content request processing, as for dynamic content or to Apache to deal with.

9.max_filedesc 16384

This is needless to say ...

10. To be continued.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.