<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>gjw_apparitor 博客 &#187; Cache</title>
	<atom:link href="http://www.apparitor.info/category/service/cache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.apparitor.info</link>
	<description>孤独是一种态度</description>
	<lastBuildDate>Wed, 16 May 2012 07:36:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Squid 防盗链配置</title>
		<link>http://www.apparitor.info/2011/04/06/squid-%e9%98%b2%e7%9b%97%e9%93%be%e9%85%8d%e7%bd%ae/</link>
		<comments>http://www.apparitor.info/2011/04/06/squid-%e9%98%b2%e7%9b%97%e9%93%be%e9%85%8d%e7%bd%ae/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 07:06:48 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Cache]]></category>
		<category><![CDATA[Squid]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=256</guid>
		<description><![CDATA[acl URL url_regex -i .* acl DOMAIN referer_regex -i .www.baidu.com www.google.com ＃允许的引用的域名 http_access allow URL DOMAIN acl NULLREF referer_regex -i ^$ ＃这个是直接用URL访问，没有引用页。 http_access allow NULLREF acl hasref referer_regex -i .+ ＃不在允许的引用域名里的都拒绝 http_access deny hasref doubanurl 原创文章，转载请注明： 转载自gjw_apparitor 博客 本文链接地址: Squid 防盗链配置]]></description>
			<content:encoded><![CDATA[<p>acl URL url_regex -i .*<br />
acl DOMAIN referer_regex -i .www.baidu.com www.google.com ＃允许的引用的域名<br />
http_access allow URL DOMAIN<br />
acl NULLREF referer_regex -i ^$ 	＃这个是直接用URL访问，没有引用页。<br />
http_access allow NULLREF<br />
acl hasref referer_regex -i .+    	＃不在允许的引用域名里的都拒绝<br />
http_access deny hasref doubanurl
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/squid-%e9%98%b2%e7%9b%97%e9%93%be%e9%85%8d%e7%bd%ae/">Squid 防盗链配置</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/squid-%e9%98%b2%e7%9b%97%e9%93%be%e9%85%8d%e7%bd%ae/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>squid 详解</title>
		<link>http://www.apparitor.info/2011/04/06/squid-%e8%af%a6%e8%a7%a3/</link>
		<comments>http://www.apparitor.info/2011/04/06/squid-%e8%af%a6%e8%a7%a3/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 07:04:05 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Cache]]></category>
		<category><![CDATA[Squid]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=252</guid>
		<description><![CDATA[一、squid安装 http://www.squid-cache.org/Versions/v2/2.6/cfgman/index.html tar zxvf squid-2.6.STABLE22.tar.gz cd squid-2.6.STABLE22 ./configure &#8211;prefix=/home/squid &#8211;enable-dlmalloc \ &#8211;enable-gnuregex \ &#8211;enable-async-io \ &#8211;enable-storeio=aufs,diskd,ufs \ &#8211;enable-snmp \ &#8211;enable-cachemgr-hostname \ &#8211;enable-arp-acl \ &#8211;enable-large-cache-files \ &#8211;disable-internal-dns \ &#8211;disable-ident-lookups \ &#8211;enable-truncate \ &#8211;with-maxfd=655360 \ &#8211;enable-forw-via-db \ &#8211;enable-cache-digests \ &#8211;enable-referer-log \ &#8211;enable-useragent-log \ &#8211;enable-delay-pools \ &#8211;enable-kill-parent-hack \ &#8211;enable-carp \ &#8211;enable-icmp \ &#8211;enable-poll \ &#8211;with-pthreads \ &#8211;enable-ssl make]]></description>
			<content:encoded><![CDATA[<p>一、squid安装</p>
<p>http://www.squid-cache.org/Versions/v2/2.6/cfgman/index.html</p>
<p>tar zxvf squid-2.6.STABLE22.tar.gz<br />
cd squid-2.6.STABLE22<br />
./configure &#8211;prefix=/home/squid &#8211;enable-dlmalloc \<br />
&#8211;enable-gnuregex \<br />
&#8211;enable-async-io \<br />
&#8211;enable-storeio=aufs,diskd,ufs \<br />
&#8211;enable-snmp \<br />
&#8211;enable-cachemgr-hostname \<br />
&#8211;enable-arp-acl \<br />
&#8211;enable-large-cache-files \<br />
&#8211;disable-internal-dns \<br />
&#8211;disable-ident-lookups \<br />
&#8211;enable-truncate \<br />
&#8211;with-maxfd=655360 \<br />
&#8211;enable-forw-via-db \<br />
&#8211;enable-cache-digests \<br />
&#8211;enable-referer-log \<br />
&#8211;enable-useragent-log \<br />
&#8211;enable-delay-pools \<br />
&#8211;enable-kill-parent-hack \<br />
&#8211;enable-carp \<br />
&#8211;enable-icmp \<br />
&#8211;enable-poll \<br />
&#8211;with-pthreads \<br />
&#8211;enable-ssl<br />
make<br />
make install<br />
<span id="more-252"></span></p>
<p>二、配置文件详解</p>
<p>1.验证选项<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
auth_param<br />
authenticate_cache_garbage_interval<br />
authenticate_ttl<br />
authenticate_ip_ttl<br />
authenticate_ip_shortcircuit_ttl</p>
<p>2.访问控制<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
external_acl_type ip_user_helper 用户IP 用户名 file<br />
file: ip_addr[/mask] user|@group|all|NONE<br />
192.168.1.0/24 NONE            禁止这个网段的访问<br />
10.10.10.10 apparitor            允许这个用户访问<br />
acl ALL src 0.0.0.0/0.0.0.0           ＃设置访问控制列表这个在squid里经常用。<br />
http_access allow ALL            ＃允许所有，ALL就是刚才acl定义的。 http_access ＃ 顺序很重要。<br />
http_access2            ＃在允许和拒绝的基础上在定义访问控制列表。<br />
http_reply_access            ＃判断原始服务器 HTTP响应里的 Content-Type头部，<br />
例： acl MP3 rep_mime_type audio/mpeg            ＃定义一个头部类型。<br />
http_reply_access deny MP3            ＃拒绝audio/mpeg的头部信息。<br />
icp_access            ＃根据IP段的访问控制<br />
例: acl IP src 10.10.10.10<br />
icp_access deny IP            ＃拒绝这个IP的访问。<br />
htcp_access deny IP            ＃拒绝这个IP清除缓存的内容。<br />
htcp_clr_access deny IP           ＃<br />
miss_access ＃<br />
ident_lookup_access            ＃是否对客户端的TCP连接发起RFC 1413身份查询。<br />
reply_body_max_size            ＃限制HTTP响应主体的最大可接受的大小。如果超出范围将收到错误信息。集群时最好禁用它。</p>
<p>3.X－Forwarded-For<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
follow_x_forwarded_for allow all           ＃让后端的web服务器获取的是客户的IP不是cache 的。需要修该一下web的log格式。<br />
acl_uses_indirect_client<br />
delay_pool_uses_indirect_client<br />
log_uses_indirect_client</p>
<p>4.网络选项<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
http_port 80 3180           ＃指定squid在哪个端口监听<br />
https_port 8080 cert=file key=file           ＃用来处理加密的HTTP（SSL、TLS）,file是openssl证书和私钥的路径。<br />
tcp_outgoing_tos 0&#215;00 IP           ＃该访问列表能设置到原始服务器和邻居 cache的 TCP 连接的不同 TOS/Diffserv 值</p>
<p>5.SSL 选项<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
ssl_unclean_shutdown on            ＃解决某些浏览器不能正确关闭ssl连接。消除了断开的客户端的错误消息。<br />
ssl_engine<br />
sslproxy_client_certificate<br />
sslproxy_clent_key<br />
sslproxy_version<br />
sslproxy_options<br />
sslproxy_cipher<br />
sslproxy_cafile<br />
sslproxy_capath<br />
sslproxy_flags<br />
sslproxy_program</p>
<p>6.邻居间的cache访问<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
cache_peer            ＃邻居间的访问<br />
        例：cache_peer hostname type http-port icp-port [options]<br />
            cache_peer 10.10.11.128 parent 80 3130 proxy-only default<br />
cache_peer_domain<br />
cache_peer_access            ＃对邻居间的访问控制列表<br />
neighbor_type_domain           ＃改变基于原始服务器的邻居cache关系。<br />
dead_peer_timeout            ＃不接受来自死亡邻居的 ICP/HTCP 响应<br />
hierarchy_stoplist ? cgi-bin            ＃将 ? cgi-bin标记为不可层叠。<br />
1)从不对不可层叠的请求发送 ICP/HTCP 查询,除非该请求匹配 never_direct 规则;<br />
2)从不对不可层叠的请求发送 ICP/HTCP 查询到姐妹 cache;<br />
3)从不对不可层叠的请求查询邻居的 cache digest。</p>
<p>7.内存cache选项<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
cache_mem 1024 MB            ＃指定内存总cache的大小。<br />
maximum_object_size_in_memory            ＃单个对象在内存中最大的大小。<br />
memory_replacement_policy heap LRU           ＃内存的替换算法。默认是LRU<br />
例： heap GDSF : Greedy-Dual Size Frequency<br />
heap LFUDA: Least Frequently Used with Dynamic Aging<br />
heap LRU : LRU policy implemented using a heap</p>
<p>8.硬盘cache 选项。<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
cache_replacement_policy           ＃物理硬盘的替换算法<br />
例： lru : Squid&#8217;s original list based LRU policy<br />
                heap GDSF : Greedy-Dual Size Frequency<br />
                heap LFUDA: Least Frequently Used with Dynamic Aging<br />
                heap LRU : LRU policy implemented using a heap</p>
<p>cache_dir aufs /cache0 4096 16 256            ＃物理cache设置。<br />
store_dir_select_algorithm            ＃设置轮询，一种替换算法。<br />
max_open_disk_fds 0            ＃允许最大打开的文件数量。0无限制。<br />
minimum_object_size            ＃缓存最小文件的大小（default:0）<br />
maximum_object_size            ＃缓存最大文件的大小（4096 KB）<br />
cache_swap_low            ＃cache 使用率最小值<br />
cache_swap_high           ＃cache 使用率的最大值</p>
<p>9.log文件的选项。<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
logformat            ＃定义squid log格式。<br />
access_log            ＃客户端使用代理服务器的记录文件<br />
log_access<br />
cache_log            ＃CACHE的启动以及各类状态的记录文件<br />
cache_store_log           ＃存储缓冲对象的状态记录文件<br />
cache_swap_state            ＃swap.state 的<br />
logfile_rotate 5            ＃设置日志替换策略的squid -k rotate 替换日志<br />
emulate_httpd_log [off|on]            ＃激活日志模式［原始模式|普通格式］<br />
log_ip_on_direct [on|off]            ＃设定squid在转发时第9段记录［IP|主机名］<br />
mime_table $path            ＃mime列表　mime 一种2进制的表<br />
log_mime_hdrs [off|on]           ＃［不记录|记录］HTTP 请求和响应的头部<br />
useragent_log $path            ＃记录User-Agent头部信息 [--enable-useragent-log]<br />
referrer_log $path            ＃<br />
pid_filename $path            ＃squid 进程号记录文件<br />
debug_options ALL,1           ＃设定日志级别默认是1级。<br />
log_fqdn [off|on]           ＃设定指令［取|不取］唯一的值<br />
client_netmask 255.255.255.255            ＃设定access.log里的客户IP地址显示的位数。 例：client_netmask 255.255.255.0 再看access的日志里客户IP最后一位为0<br />
forward_log $path            ＃[--enable-forward-log]<br />
strip_query_terms [on|off]            ＃[显示|不显示]?号后边的内容。<br />
buffered_logs [off|on]            ＃[禁止|允许]写cache.log的buffer</p>
<p>10、FTP 网关选项<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
ftp_user Squid@域名            ＃squid ftp认证模式 用户名认证<br />
ftp_list_width 32           ＃设置ftp列表的宽度如果设得太小，将不能浏览到长 文件名<br />
ftp_passive [on|off]            ＃［启用|关闭］ftp被动模式<br />
ftp_sanitycheck ［on|off］           ＃<br />
ftp_telnet_protocol [on|off]            ＃</p>
<p>11、外部支持选项<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
diskd_program $path/diskd-daemon            ＃磁盘管理程序<br />
unlinkd_program $path/libexec/unlinkd            ＃删除文件程序［&#8211;enable-unlinkd］<br />
pinger_program $path/libexec/pinger           ＃ping 程序[--enable-icmp]</p>
<p>12、RUL从写选项<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
url_rewrite_program            ＃URL重定向程序<br />
url_rewrite_children 5            ＃重定向进程数<br />
url_rewrite_concurrency 0           ＃定义重定向的并发数。<br />
url_rewrite_host_header [on/off]            ＃［开启|关闭］重定向时重写包头。（）<br />
url_rewrite_access $acl           ＃对指定的URL改写<br />
redirector_bypass［off|on］           ＃设置为on时，当所有URL改写程序处于高负载，不能再提供改写时，多出的请求不再通过URL改写。直接由squid处理<br />
location_rewrite_program            ＃<br />
location_rewrite_children 5            ＃<br />
location_rewrite_concurrency 0           ＃<br />
location_rewrite_access            ＃</p>
<p>13、设置cache的选项<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
cache deny $acl            ＃不缓存某些URL<br />
refresh_pattern －i .*\.gif 1440 20% 10080            ＃设定缓存类型时间<br />
quick_abort_min 16 KB            ＃断点续传的最小值<br />
quick_abort_max 16 KB            ＃断点续传的最大值<br />
quick_abort_pct 95            ＃断点续传的百分比<br />
read_ahead_gap 16 KB<br />
negative_ttl 5 minutes            ＃错误页面的缓存时间5分钟<br />
positive_dns_ttl 6 hours           ＃正确的DNS缓存时间6小时。<br />
negative_dns_ttl 1 minute           ＃错误的DNS缓存时间安1分钟<br />
range_offset_limit 0 KB            ＃主要是对各种流媒体和要断点续传的文件的缓存的。缺省是0，也就是说只要client发过来的http header里包含了“Range:” ，squid会把这个请求转到后端http server，最致命的是，http server返回的内容并不会进入squid的cache store。把它的值设置为-1；然后squid会把Range头去掉，而从后端http server把内容全部抓下来，放到cache store里，随后的对该cache的访问就不再转发到后端http server，可以大大提高命中率。也可以给这个参数设置一个值,会提前下载多少内容.但要注意，这个参数不要大过 maximum_object_size ，不然下载完了,maximum_object_size 这个参数不能缓存这么多,又删除这个文件.白白点用你的流量.<br />
minimum_expiry_time 60 seconds            ＃设置最的小新鲜值<br />
store_avg_object_size 13 KB            ＃平均每个存储块的大小。<br />
store_objects_per_bucket 20           ＃希望每个存储块可存储多少对象</p>
<p>14、HTTP选项<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
request_header_max_size 20 KB            ＃HTTP请求包头的大小<br />
reply_header_max_size 20 KB            ＃HTTP答复包头的大小<br />
request_body_max_size 0 KB            ＃HTTP数据请求的大小。0为没有限制。<br />
broken_posts allwo $ACL<br />
via [on|off]            ＃检测HTTP Via头的主机名，防止发生死循环。&#8211;enable-http-violations<br />
cache_vary ［on|off］            ＃使squid缓存有 Vary HTTP头 的文件。<br />
broken_vary_encoding           ＃<br />
collapsed_forwarding [off|on]            ＃[不允许|允许]多个请求相同的URL处理一个请求。如果是静态内容可以加快速度。如果是动态内容会影响速度。<br />
refresh_stale_hit 0 seconds            ＃<br />
ie_refresh ［off|on]            ＃解决IE 5.5以前的一个刷新BUG。<br />
vary_ignore_expire［off|on]            ＃<br />
extension_methods $ACL            ＃squid除了了解HTTP 方法:GET, POST, PUT, HEAD, CONNECT, TRACE,OPTIONS 和 DELETE。还了解其他方法。需要在这里声明。<br />
request_entities [off|on]            ＃[禁止|允许]非HTTP头的请求。防止攻击。<br />
header_access $ACl           ＃squid 从它转发的请求里删除某些 HTTP 头部[--enable-http-violations]<br />
例： header_access header allow all 允许转发所有的HTTP头。<br />
header_replace $ACL           ＃该指令允许你替换,而不是删除,HTTP 头部的内容。[--enable-http-violations]<br />
relaxed_header_parser [on|off]            ＃不严格分析http头</p>
<p>15、超时选项<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
forward_timeout 4 minutes           ＃<br />
connect_timeout 1 minute            ＃与邻居建立TCP连接超时的时间。<br />
peer_connect_timeout 30 seconds            ＃连接到上层代理的超时时间<br />
read_timeout 15 minutes            ＃用于和服务器连接的超时时间。<br />
request_timeout 5 minutes           ＃等待HTTP建立的时间<br />
persistent_request_timeout 2 minutes           ＃这个是KeepAlive连接超时时间<br />
client_lifetime 1 day            ＃对单个 HTTP 请求的存活期设置一个上限。<br />
half_closed_clients [on|off]            ＃使squid在当read(2)不再返回数据时[关闭|不关闭]客户端的连接。<br />
pconn_timeout 1 minute            ＃设置闲置连接的超时时间。<br />
ident_timeout 10 seconds            ＃设置squid等待用户认证请求的时间。缺省值为10秒。［&#8211;enable-ident-lookups］<br />
shutdown_lifetime 30 seconds            ＃设置squid 接受关闭信号后生存的时间。<br />
16、管理参数<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
cache_mgr gjw_apparitor@hotmail.com           ＃设置遇到问题发送的邮箱地址<br />
mail_from<br />
mail_program mail           ＃指定squid用什么发送邮件<br />
cache_effective_user nobody            ＃运行squid的用户<br />
cache_effective_group            ＃运行squid的组<br />
httpd_suppress_version_string [off|on]           ＃[显示|不显示]有squid版本信息的错误页面<br />
visible_hostname mysquid           ＃指定squid的主机名多用于集群<br />
unique_hostname            ＃如果你有一个代理服务器阵列，并且你为每个代理服务器指定了同样的“visible_hostname”，同时你必须为它们指定不同的“unique_hostname”来避免“forwarding loops ”（传输循环）发生。<br />
hostname_aliases            ＃指定一个主机别名用于DNS查询<br />
umask 027            ＃ squdi默认的权限umask</p>
<p>17、声明其他服务 OPTIONS FOR THE CACHE REGISTRATION SERVICE<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
announce_period 0           ＃声明多常时间发送邮件0是禁用。<br />
announce_host $name           ＃声明主机明<br />
announce_file            ＃通告的信息<br />
announce_port            ＃声明端口</p>
<p>18、 http加速选项 HTTPD-ACCELERATOR OPTIONS<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
    httpd_accel_no_pmtu_disc off    ＃</p>
<p>19、限速参数 DELAY POOL PARAMETERS<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
delay_pools 0           ＃表示有多少个限制池 ［&#8211;enable-delay-pools］<br />
delay_class 1           ＃声明池的类型［&#8211;enable-delay-pools］<br />
delay_access           ＃定义池规则［&#8211;enable-delay-pools］<br />
delay_parameters           ＃［&#8211;enable-delay-pools］<br />
delay_initial_bucket_level 50           ＃［&#8211;enable-delay-pools］</p>
<p>20、WCCPv1和WCCPv2 配置选项 WCCPv1 AND WCCPv2 CONFIGURATION OPTIONS<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
wccp_router 0.0.0.0          ＃路由器不发送任何会话到 squid,直到 squid 宣称它自己是路由器［&#8211;enable-wccp］<br />
wccp2_router           ＃［&#8211;enable-wccpv2］<br />
wccp_version 4           ＃[--enable-wccp]<br />
wccp2_rebuild_wait on           ＃［&#8211;enable-wccpv2］<br />
wccp2_forwarding_method 1           ＃［&#8211;enable-wccpv2］<br />
wccp2_return_method 1           ＃［&#8211;enable-wccpv2］<br />
wccp2_assignment_method 1           ＃［&#8211;enable-wccpv2］<br />
wccp2_service           ＃［&#8211;enable-wccpv2］<br />
wccp2_service_info           ＃［&#8211;enable-wccpv2］<br />
wccp2_weight 10000           ＃［&#8211;enable-wccpv2］<br />
wccp_address 0.0.0.0           ＃［&#8211;enable-wccp］<br />
wccp2_address 0.0.0.0           ＃［&#8211;enable-wccpv2］</p>
<p>21、长久的连接处理 PERSISTENT CONNECTION HANDLING<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
client_persistent_connections ［on|off］          ＃对客户端长连接KeepAlive.这个参数的支持,默认是打开的.现在的客户端浏览器基本都支持的.<br />
server_persistent_connections [on|off]          ＃［允许 |禁止］服务器持久连接<br />
persistent_connection_after_error [off|on]           ＃<br />
detect_broken_pconn [off|on]           ＃<br />
22、CACHE DIGEST OPTIONS<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
digest_generation [on|off]                  ＃控制 squid 是否产生自己的 cache 摘要。假如你的 cache 是一个子 cache,而不是其他任何 cache 的父或姐妹 cache,那么你也许想禁止产生摘要。[--enable-cache-digests]<br />
digest_bits_per_entry 5                ＃决定摘要的大小。默认值是 5。增加该值导致更大的摘要(浪费更多内存和带宽)和更低的假命中可能性。[--enable-cache-digests]<br />
digest_rebuild_period 1 hour                  ＃控制 squid 重建摘要数据结构(并非 HTTP 响应)的频率。默认是每个小时 1 次。[--enable-cache-digests]<br />
digest_rewrite_period 1 hour          ＃ 控制 squid 从摘要数据结构创建 HTTP 响应的频率。大部分情形下,这个频率应该匹配 digest_rebuild_period 值。[--enable-cache-digests]<br />
digest_swapout_chunk_size 4096 bytes          ＃添加多大数量的摘要数据结构到 cache 条目里[--enable-cache-digests]<br />
digest_rebuild_chunk_percentage 10           ＃指令控制每次调用重建函数时,多少 cache 增加到摘要里.默认是 10%。［&#8211;enable-cache-digests］<br />
23、 SNMP 选项 SNMP OPTIONS<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
snmp_port 3401           ＃snmp的端口 0是关闭[--enable-snmp]<br />
snmp_access allow $ACL          ＃[--enable-snmp]<br />
snmp_incoming_address 0.0.0.0          ＃[--enable-snmp]<br />
snmp_outgoing_address 255.255.255.255          ＃[--enable-snmp]</p>
<p>24、ICP配置<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
icp_port 3130          ＃ICP通讯端口，squid 自动成为 ICP 服务器，它在你指定的端口侦听ICP 消息。<br />
htcp_port 4827           ＃HTCP端口，squid 默认变成HTCP 服务器。[--enable-htcp]<br />
例：cache_peer neighbor.host.name parent 3128 4827 htcp<br />
log_icp_queries [on|off] ＃[打开|关闭]access.log日志记录<br />
udp_incoming_address 0.0.0.0 ＃squid将所有的UDP绑定到指定的网络接口，ip-address必须对应于系统的网络接口。它将影响DNS（当使用内部DNS时）、ICP、HTCP、SNMP。如果系统只有一个IP地址，该选项不能工作。如果设置udp_outgoing_address为其他的网络接口地址，squid将在那个网络接口上接收UDP数据报。<br />
udp_outgoing_address 255.255.255.255           ＃<br />
icp_hit_stale off           ＃如果是on忽略父cache的陈旧的但没过期的文件返回ICP_HIT 否则返回ICP_MISS<br />
minimum_direct_hops 4          ＃squid 直接连接到低于一定数量路由跳计数 , 匹配该标准的请求在access.log里以CLOSEST_DIRECT 形式记载。<br />
minimum_direct_rtt 400           ＃squid 直接连接到低于一定毫秒的原始服务器。匹配该标准的请求在access.log里以CLOSEST_DIRECT形式记载。<br />
netdb_low 900          ＃netdb_low 和 netdb_high 指令控制度量数据库的大小。当存储子网的数量抵达 netdb_high 时,squid 删除最少近来使用的条目,直到数量低netdb_low<br />
netdb_high 1000<br />
netdb_ping_period 5 minutes           ＃ 默认的,squid 在发送另一个 ping 到同一主机,或同一 24 位子网中主机时,会至少等待 5 分钟。可以使用 netdb_ping_period 指令来调整这个时间间隙。<br />
query_icmp off           ＃测试一个或多个邻居 cache。<br />
test_reachability off           ＃激活了 test_reachability指令,在原始服务器不响应 ICMP ping 时,squid 返回 ICP_MISS_NOFETCH,而不是ICP_MISS。这点有助于减少假 HTTP 请求的数量,并增加终端用户迅速接受数据的机会。然而, 一定比率的原始服务器站点过滤掉了 ICMP 传输。 对这些站点,即使 HTTP 连接成功,<br />
squid 也会返回 ICP_MISS_NOFETCH。<br />
icp_query_timeout 0          ＃设置ICP超时时间。<br />
maximum_icp_query_timeout 2000          ＃设置ICP超时的上限<br />
minimum_icp_query_timeout 5           ＃设置ICP超时的最小值</p>
<p>多点通信ICP选项 MULTICAST ICP OPTIONS<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
mcast_groups           ＃设置广播地址<br />
mcast_miss_addr 255.255.255.255          ＃ [--enable-multicast-miss]<br />
mcast_miss_ttl 16          ＃[--enable-multicast-miss]<br />
mcast_miss_port 3135          ＃[--enable-multicast-miss]<br />
mcast_miss_encode_key           ＃设定网络组的key[--enable-multicast-miss]<br />
mcast_icp_query_timeout 2000           ＃</p>
<p>内部图标选项 INTERNAL ICON OPTIONS<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
icon_directory /usr/local/squid/share/icons          ＃指明向用户传送错误信息时所用到的图标文件的目录<br />
global_internal_static on           ＃<br />
short_icon_urls off          ＃</p>
<p>错误页面选项ERROR PAGE OPTIONS<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
    error_directory /usr/local/squid/share/errors/English              ＃设定错误页面的语言<br />
    error_map            $URL 404 ＃指定返回的错误信息<br />
    err_html_text                  ＃<br />
deny_info           ＃你可以定制自定义的拒绝访问信息文件，并且可以和不同的用户列表相关联。当用户被http_access相关规则拒绝时，squid可以向用户显示你自定义的相应的拒绝访问信息文件。<br />
例： deny_info http://www.baidu.com/logs.gif tianya</p>
<p>转发请求选项 OPTIONS INFLUENCING REQUEST FORWARDING<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
nonhierarchical_direct on           ＃该指令控制 squid 转发不可层叠的请求的方法。squid 默认直接发送不可层叠的请求到原始服务器。这是因为这些请求不会导致 cache 命中。<br />
prefer_direct off           ＃该指令控制 squid 转发层叠请求的方法。默认的,squid 首先发送这样的请求到邻居 cache,然后再到原始服务器<br />
always_direct           ＃该访问列表影响 squid 怎样处理与邻居 cache 转发 cache 丢失。通常 squid 试图转发 cache<br />
never_direct          ＃ never_direct 与 always_direct 相反。匹配该列表的 cache 丢失请求必须发送到邻居 cache。<br />
这点对在防火墙之后的代理特别有用。</p>
<p>高级的网络选项ADVANCED NETWORKING OPTIONS<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
incoming_icp_average 6           ＃<br />
incoming_http_average 4           ＃<br />
incoming_dns_average 4           ＃<br />
min_icp_poll_cnt 8          ＃<br />
min_dns_poll_cnt 8          ＃<br />
min_http_poll_cnt 8          ＃<br />
tcp_recv_bufsize 0 bytes           ＃</p>
<p>DNS选项DNS OPTIONS<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
check_hostnames on          ＃<br />
allow_underscore on           ＃<br />
cache_dns_program /usr/local/squid/libexec/dnsserver          ＃指定DNS查询程序的完整路径（包括文件的名称及所在的目录）。[--disable-internal-dns]<br />
dns_children 5          ＃DNS解析的进程数[--disable-internal-dns]<br />
dns_retransmit_interval 5 seconds           ＃[--enable-internal-dns]<br />
dns_timeout 2 minutes           ＃dns解析超时时间[--enable-internal-dns]<br />
dns_defnames off ＃<br />
dns_nameservers $IP           ＃指定DNS内部服务器<br />
hosts_file /etc/hosts          ＃读取hosts的位置<br />
dns_testnames          ＃指令来指定你自己的主机名。只要接受到响应,squid 就会认为 DNS 测试成功。<br />
append_domain          ＃<br />
ignore_unknown_nameservers on          ＃<br />
ipcache_size 1024           ＃IP缓存的大小<br />
ipcache_low 90          ＃IP缓存使用的最低百分比<br />
ipcache_high 95           ＃IP缓存使用的最高百分比<br />
fqdncache_size 1024           ＃FQDN 高速缓存大小 FQDN 全域名（FQDN，Fully Qualified Domain Name）是指主机名加上全路径，全路径中列出了序列中所有域成员。</p>
<p>其他选项MISCELLANEOUS<br />
－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br />
memory_pools [on|off]          ＃关闭打开内存池<br />
memory_pools_limit 5 MB           ＃设置内存池的大小<br />
forwarded_for on          ＃squid的IP地址会在HTTP请求中转反<br />
cachemgr_passwd          ＃设定管理端口密码<br />
client_db [on|off]          ＃[打开|关闭]客户端信息统计<br />
reload_into_ims off          ＃设置on这个参数违反 HTTP 协议,但是对大部分网站来说是可以设置为 on 的，只要后端服务器对If-Modified-Since 头的判断正确即可。[--enable-http-violations]<br />
maximum_single_addr_tries 1           ＃ 同一个IP的最大连接数<br />
retry_on_error off ＃<br />
as_whois_server whois.ra.net           ＃<br />
offline_mode off          ＃当 offline_mode on时,Squid 对任何 cache 响应返回 cache 命中,而不用考虑它的新鲜程度。<br />
uri_whitespace strip           ＃<br />
coredump_dir          ＃<br />
chroot ＃<br />
balance_on_multiple_ip on           ＃<br />
pipeline_prefetch off           ＃<br />
high_response_time_warning 0
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/squid-%e8%af%a6%e8%a7%a3/">squid 详解</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/squid-%e8%af%a6%e8%a7%a3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>squid manage</title>
		<link>http://www.apparitor.info/2011/04/06/squid-manage/</link>
		<comments>http://www.apparitor.info/2011/04/06/squid-manage/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 07:03:01 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Cache]]></category>
		<category><![CDATA[Squid]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=250</guid>
		<description><![CDATA[基本的使用方法 # /home/squid/bin/squidclient -p 80 mgr:menu 管理界面 取得squid运行状态信息： squidclient -p 80 mgr:info 取得squid内存使用情况： squidclient -p 80 mgr:mem 取得squid已经缓存的列表： squidclient -p 80 mgr:objects ＃可能会引起squid崩溃。 取得squid的磁盘使用情况： squidclient -p 80 mgr:diskd 取得squid ipcache状态信息squidclient -p 80 mgr:ipcache squidclient -p 80 mgr:info HTTP/1.0 200 OK Server: squid/2.6.STABLE21 Date: Mon, 11 May 2009 06:52:59 GMT Content-Type: text/plain Expires: Mon, 11 May]]></description>
			<content:encoded><![CDATA[<p>基本的使用方法<br />
# /home/squid/bin/squidclient -p 80 mgr:menu<br />
管理界面<br />
取得squid运行状态信息： squidclient -p 80 mgr:info<br />
取得squid内存使用情况： squidclient -p 80 mgr:mem<br />
取得squid已经缓存的列表： squidclient -p 80 mgr:objects ＃可能会引起squid崩溃。<br />
取得squid的磁盘使用情况： squidclient -p 80 mgr:diskd<br />
取得squid ipcache状态信息squidclient -p 80 mgr:ipcache</p>
<p><span id="more-250"></span>squidclient -p 80 mgr:info<br />
HTTP/1.0 200 OK<br />
Server: squid/2.6.STABLE21<br />
Date: Mon, 11 May 2009 06:52:59 GMT<br />
Content-Type: text/plain<br />
Expires: Mon, 11 May 2009 06:52:59 GMT<br />
Last-Modified: Mon, 11 May 2009 06:52:59 GMT<br />
X-Cache: MISS from cdn.okglb.com<br />
X-Cache-Lookup: MISS from cdn.okglb.com:80<br />
Via: 1.0 cdn.okglb.com:80 (squid/2.6.STABLE21)<br />
Connection: close<br />
Squid Object Cache: Version 2.6.STABLE21<br />
Start Time: Sun, 10 May 2009 15:58:28 GMT<br />
Current Time: Mon, 11 May 2009 06:52:59 GMT<br />
Connection information for squid:<br />
Number of clients accessing cache: 19          ＃使用proxy的电脑数量<br />
Number of HTTP requests received: 106364           ＃客户端请求Http数量<br />
Number of ICP messages received: 0         ＃接受ICP数量<br />
Number of ICP messages sent: 0             ＃发出ICP数量<br />
Number of queued ICP replies: 0<br />
Number of HTCP messages received: 0<br />
Number of HTCP messages sent: 0<br />
Request failure ratio: 0.00<br />
Average HTTP requests per minute since start: 118.9           ＃每分钟http请求的数量。<br />
Average ICP messages per minute since start: 0.0<br />
Select loop called: 6403078 times, 8.382 ms avg<br />
Cache information for squid:<br />
Request Hit Ratios: 5min: 78.6%, 60min: 82.2%           ＃cache请求的命中率<br />
Byte Hit Ratios: 5min: 82.5%, 60min: 81.6%            ＃cache字节命中率<br />
Request Memory Hit Ratios: 5min: 33.7%, 60min: 30.4%           ＃memory命中率<br />
Request Disk Hit Ratios: 5min: 46.3%, 60min: 37.4%        ＃Disk命中率<br />
Storage Swap size: 6765136 KB ＃swap的使用大小<br />
Storage Mem size: 205920 KB        ＃memory使用的大小<br />
Mean Object Size: 35.71 KB            ＃平均单个文件的大小<br />
Requests given to unlinkd: 0<br />
Median Service Times (seconds) 5 min 60 min:<br />
HTTP Requests (All): 0.02190 0.01387<br />
Cache Misses: 0.12783 0.11465<br />
Cache Hits: 0.01164 0.01035<br />
Near Hits: 0.55240 0.55240<br />
Not-Modified Replies: 0.00598 0.00678<br />
DNS Lookups: 0.00000 0.00000<br />
ICP Queries: 0.00000 0.00000<br />
Resource usage for squid:<br />
UP Time: 53671.062 seconds<br />
CPU Time: 82.097 seconds<br />
CPU Usage: 0.15%<br />
CPU Usage, 5 minute avg: 0.09%<br />
CPU Usage, 60 minute avg: 0.41%<br />
Process Data Segment Size via sbrk(): 293608 KB<br />
Maximum Resident Size: 0 KB<br />
Page faults with physical i/o: 4<br />
Memory usage for squid via mallinfo():<br />
Total space in arena: 293620 KB<br />
Ordinary blocks: 293591 KB 42 blks<br />
Small blocks: 0 KB 0 blks<br />
Holding blocks: 239568 KB 6 blks<br />
Free Small blocks: 0 KB<br />
Free Ordinary blocks: 28 KB<br />
Total in use: 533159 KB 100%<br />
Total free: 28 KB 0%<br />
Total size: 533188 KB<br />
Memory accounted for        :＃内存使用状态<br />
Total accounted: 279610 KB<br />
memPoolAlloc calls: 13292872<br />
memPoolFree calls: 12494740<br />
File descriptor usage for squid:                  ＃文件描述符的状态<br />
Maximum number of file descriptors: 65536 0 ＃最大文件描述符数<br />
Largest file desc currently in use: 74                ＃目前使用文件描述符最大值。<br />
Number of file desc currently in use: 60           ＃目前正在使用文件描述符数。<br />
Files queued for open: 0<br />
Available number of file descriptors: 655300<br />
Reserved number of file descriptors: 100<br />
Store Disk files open: 0<br />
IO loop method: epoll<br />
Internal Data Structures:<br />
189669 StoreEntries<br />
＃<br />
7835 StoreEntries with MemObjects    ＃内存放快取文件的数量<br />
7834 Hot Object Cache Items        ＃硬盘存放快取文件数量<br />
189469 on-disk objects            ＃在硬盘文件的总数量</p>
<p>基本的使用方法<br />
# /home/squid/bin/squidclient -p 80 mgr:menu<br />
管理界面<br />
取得squid运行状态信息： squidclient -p 80 mgr:info<br />
取得squid内存使用情况： squidclient -p 80 mgr:mem<br />
取得squid已经缓存的列表： squidclient -p 80 mgr:objects ＃可能会引起squid崩溃。<br />
取得squid的磁盘使用情况： squidclient -p 80 mgr:diskd<br />
取得squid ipcache状态信息squidclient -p 80 mgr:ipcache<br />
squidclient -p 80 mgr:info<br />
HTTP/1.0 200 OK<br />
Server: squid/2.6.STABLE21<br />
Date: Mon, 11 May 2009 06:52:59 GMT<br />
Content-Type: text/plain<br />
Expires: Mon, 11 May 2009 06:52:59 GMT<br />
Last-Modified: Mon, 11 May 2009 06:52:59 GMT<br />
X-Cache: MISS from cdn.okglb.com<br />
X-Cache-Lookup: MISS from cdn.okglb.com:80<br />
Via: 1.0 cdn.okglb.com:80 (squid/2.6.STABLE21)<br />
Connection: close<br />
Squid Object Cache: Version 2.6.STABLE21<br />
Start Time: Sun, 10 May 2009 15:58:28 GMT<br />
Current Time: Mon, 11 May 2009 06:52:59 GMT<br />
Connection information for squid:<br />
Number of clients accessing cache: 19          ＃使用proxy的电脑数量<br />
Number of HTTP requests received: 106364           ＃客户端请求Http数量<br />
Number of ICP messages received: 0         ＃接受ICP数量<br />
Number of ICP messages sent: 0             ＃发出ICP数量<br />
Number of queued ICP replies: 0<br />
Number of HTCP messages received: 0<br />
Number of HTCP messages sent: 0<br />
Request failure ratio: 0.00<br />
Average HTTP requests per minute since start: 118.9           ＃每分钟http请求的数量。<br />
Average ICP messages per minute since start: 0.0<br />
Select loop called: 6403078 times, 8.382 ms avg<br />
Cache information for squid:<br />
Request Hit Ratios: 5min: 78.6%, 60min: 82.2%           ＃cache请求的命中率<br />
Byte Hit Ratios: 5min: 82.5%, 60min: 81.6%            ＃cache字节命中率<br />
Request Memory Hit Ratios: 5min: 33.7%, 60min: 30.4%           ＃memory命中率<br />
Request Disk Hit Ratios: 5min: 46.3%, 60min: 37.4%        ＃Disk命中率<br />
Storage Swap size: 6765136 KB ＃swap的使用大小<br />
Storage Mem size: 205920 KB        ＃memory使用的大小<br />
Mean Object Size: 35.71 KB            ＃平均单个文件的大小<br />
Requests given to unlinkd: 0<br />
Median Service Times (seconds) 5 min 60 min:<br />
HTTP Requests (All): 0.02190 0.01387<br />
Cache Misses: 0.12783 0.11465<br />
Cache Hits: 0.01164 0.01035<br />
Near Hits: 0.55240 0.55240<br />
Not-Modified Replies: 0.00598 0.00678<br />
DNS Lookups: 0.00000 0.00000<br />
ICP Queries: 0.00000 0.00000<br />
Resource usage for squid:<br />
UP Time: 53671.062 seconds<br />
CPU Time: 82.097 seconds<br />
CPU Usage: 0.15%<br />
CPU Usage, 5 minute avg: 0.09%<br />
CPU Usage, 60 minute avg: 0.41%<br />
Process Data Segment Size via sbrk(): 293608 KB<br />
Maximum Resident Size: 0 KB<br />
Page faults with physical i/o: 4<br />
Memory usage for squid via mallinfo():<br />
Total space in arena: 293620 KB<br />
Ordinary blocks: 293591 KB 42 blks<br />
Small blocks: 0 KB 0 blks<br />
Holding blocks: 239568 KB 6 blks<br />
Free Small blocks: 0 KB<br />
Free Ordinary blocks: 28 KB<br />
Total in use: 533159 KB 100%<br />
Total free: 28 KB 0%<br />
Total size: 533188 KB<br />
Memory accounted for        :＃内存使用状态<br />
Total accounted: 279610 KB<br />
memPoolAlloc calls: 13292872<br />
memPoolFree calls: 12494740<br />
File descriptor usage for squid:                  ＃文件描述符的状态<br />
Maximum number of file descriptors: 65536 0 ＃最大文件描述符数<br />
Largest file desc currently in use: 74                ＃目前使用文件描述符最大值。<br />
Number of file desc currently in use: 60           ＃目前正在使用文件描述符数。<br />
Files queued for open: 0<br />
Available number of file descriptors: 655300<br />
Reserved number of file descriptors: 100<br />
Store Disk files open: 0<br />
IO loop method: epoll<br />
Internal Data Structures:<br />
189669 StoreEntries<br />
7835 StoreEntries with MemObjects    ＃内存放快取文件的数量<br />
7834 Hot Object Cache Items        ＃硬盘存放快取文件数量<br />
189469 on-disk objects            ＃在硬盘文件的总数量
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/squid-manage/">squid manage</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/squid-manage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>squid 优化</title>
		<link>http://www.apparitor.info/2011/04/06/squid-%e4%bc%98%e5%8c%96/</link>
		<comments>http://www.apparitor.info/2011/04/06/squid-%e4%bc%98%e5%8c%96/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 07:01:45 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Cache]]></category>
		<category><![CDATA[Squid]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=248</guid>
		<description><![CDATA[优化： 在 Linux 上配置消息队列,增加下列行到/etc/sysctl.conf: kernel.msgmnb=8192 kernel.msgmni=40 kernel.msgmax=8192 kernel.shmall=2097152 kernel.shmmni=32 kernel.shmmax=16777216 SQUID优化 range_offset_limit Published June 15th, 2006 in Tech range_offset_limit 主要用在优化各种多线程下载攻击和在线流媒体播放下的squid，缺省是0，也就是说只要client发过来的http header里包含了“Range:” ，squid会把这个请求转到后端http server，最致命的是，http server返回的内容并不会进入squid的cache store。 在squid刚启动时，cache store并没有多少内容，而多线程的HTTP下载又不能cache，这样会导致squid的命中率很低，squid效率差。 range_offset_limit就派上用场了，把它的值设置为-1；然后squid会把Range头去掉，而从后端http server把内容全部抓下来，放到cache store里，随后的对该cache的访问就不再转发到后端http server，大大提高命中率。 range_offset_limit设置成-1后，squid的hit rate统计可能会显示负数，是个bug，等squid把大部分后端http server的内容放到cache store后（比如1~2天），把range_offset_limit改成0，统计数据就会显示正常了。呵呵 refresh_pattern 指令也有少数选项导致 squid 违背 HTTP 协议规范。它们如下: override-expire 该选项导致 squid 在检查 Expires 头部之前,先检查 min 值。这样,一个非零的 min 时 间让 squid 返回一个未确认的 cache]]></description>
			<content:encoded><![CDATA[<p>优化：<br />
在 Linux 上配置消息队列,增加下列行到/etc/sysctl.conf:<br />
kernel.msgmnb=8192<br />
kernel.msgmni=40<br />
kernel.msgmax=8192<br />
kernel.shmall=2097152<br />
kernel.shmmni=32<br />
kernel.shmmax=16777216</p>
<p>SQUID优化 range_offset_limit<br />
Published June 15th, 2006 in Tech<br />
range_offset_limit 主要用在优化各种多线程下载攻击和在线流媒体播放下的squid，缺省是0，也就是说只要client发过来的http header里包含了“Range:” ，squid会把这个请求转到后端http server，最致命的是，http server返回的内容并不会进入squid的cache store。<br />
在squid刚启动时，cache store并没有多少内容，而多线程的HTTP下载又不能cache，这样会导致squid的命中率很低，squid效率差。 range_offset_limit就派上用场了，把它的值设置为-1；然后squid会把Range头去掉，而从后端http server把内容全部抓下来，放到cache store里，随后的对该cache的访问就不再转发到后端http server，大大提高命中率。<br />
range_offset_limit设置成-1后，squid的hit rate统计可能会显示负数，是个bug，等squid把大部分后端http server的内容放到cache store后（比如1~2天），把range_offset_limit改成0，统计数据就会显示正常了。呵呵<br />
<span id="more-248"></span>refresh_pattern 指令也有少数选项导致 squid 违背 HTTP 协议规范。它们如下:<br />
override-expire<br />
该选项导致 squid 在检查 Expires 头部之前,先检查 min 值。这样,一个非零的 min 时<br />
间让 squid 返回一个未确认的 cache 命中,即使该响应准备过期。<br />
override-lastmod<br />
改选项导致 squid 在检查 LM-factor 百分比之前先检查 min 值。<br />
reload-into-ims<br />
该选项让 squid 在确认请求里,以 no-cache 指令传送一个请求。换句话说,squid 在转<br />
发请求之前, 对该请求增加一个 If-Modified-Since 头部。注意这点仅仅在目标有 Last-Modified<br />
时间戳时才能工作。外面进来的请求保留 no-cache 指令,以便它到达原始服务器。<br />
ignore-reload<br />
该选项导致 squid 忽略请求里的任何 no-cache 指令。是针对客户端的请求<br />
客户在用浏览器时按 F5会在请求头部强制加入no-cache指令。用该选项squid会忽略这个头部。不会在去源站进行对比。<br />
Squid 2.6以后新加的refresh_pattern规则用来缓存头部有no-cache的。<br />
ignore-no-cache ignore-private<br />
range_offset_limit主要用在优化各种多线程下载攻击和在线流媒体播放下的squid，缺省是0，也就是说只要client发过来的 http header里包含了“Range:” ，squid会把这个请求转到后端http server，最致命的是，http server返回的内容并不会进入squid的cache store。<br />
在squid刚启动时，cache store并没有多少内容，而多线程的HTTP下载又不能cache，这样会导致squid的命中率很低，squid效率差。 range_offset_limit就派上用场了，把它的值设置为-1；然后squid会把Range头去掉，而从后端http server把内容全部抓下来，放到cache store里，随后的对该cache的访问就不再转发到后端http server，大大提高命中率。<br />
range_offset_limit设置成-1后，squid的hit rate统计可能会显示负数，是个bug，等squid把大部分后端http server的内容放到cache store后（比如1~2天），把range_offset_limit改成0，统计数据就会显示正常了。呵呵<br />
squid限制带宽<br />
关于设定SQUID带宽限制和流量整形,刻利用squid.conf种的delay_pools字段来完成.<br />
delay pools里的bucket就像是一个容器,而这个容器就是squid要控制带宽用的,当容器到达所设定的容量时,这个容器的所有者就无法超过我们所设定的带宽限制,所有的bucket则称之为unified bucket.<br />
Class分为三种:<br />
(1)Class 1:包含一个unified bucket,而这个bucket是给这个class里所定义的host使用.<br />
(2)Class 2:包含一个unified bucket和255个buckets,每一个bucket分配给8bit网络的使用者(255 hosts)使用IPv4 class C).<br />
(3)Class 3:包含255个buckets,每一个bucket分配给16bit网络的使用者(65535 hosts)使用(IPv4 class B).<br />
(1)Class 1:contains a single unified bucket which is used for all requests from hosts subject to the pool<br />
(2)Class 2:contains one unified bucket and 255 buckets, one for each host on an 8-bit network (IPv4 class C)<br />
(3)Class 3:contains 255 buckets for the subnets in a 16-bit network, and individual buckets for every host on these networks (IPv4 class B)<br />
推测:如果ACL只定义一个class C字段,要限制每个host的单一带宽,可以使用Class 2来做；但如果ACL有定义好几个class C字段,使用Class 3可再对各个class C字段做个别的总带宽限制<br />
delay_parameters语法:<br />
class 1 delay pool;<br />
delay_parameters pool total<br />
class 2 delay pool;<br />
delay_parameters pool tatal per-host<br />
class 3 delay pool;<br />
delay_parameters pool total network per-host<br />
每个delay_parameters的数值是由restore(byte/sec)/max(bytes)组成,restore是表示以bytes/sec的速度下载object到bucket里,而max则表示bucket的bytes值.<br />
备注1:如果要设定为unilit speed的话,将数值设定为-1即可<br />
备注2:SQUID FAQ中有提到,建议max至少要设为restore的两倍(It is recommended that the maximum is at least twice the restore value)<br />
[设定文档格式说明]<br />
acl all src 0.0.0.0/0.0.0.0<br />
acl lan src 192.168.1.0/255.255.255.0 ＃ 定义 ACL<br />
delay_pools n ＃ 总共有几个 delay_pools<br />
delay_class n1 1 ＃ 第 n1 个 delay_pool 的种类是 Class 1<br />
delay_class n2 3 ＃第 n2 个 delay_pool 的种类是 Class 3<br />
delay_class n3 2 ＃ 第 n3 个 delay_pool 的种类是 Class 2<br />
delay_access n1 allow lan<br />
delay_access n1 deny all ＃ 定义 delay_pool n1 的 access rule<br />
delay_parameters n1 64000/64000 ＃ 定义 delay_pool n1 的速度限制,依 class 的不同有不同的定义方式 (请参照上面的说明)<br />
[范例说明]<br />
1. 限制限制带宽为 512 Kbps<br />
acl all src 0.0.0.0/0.0.0.0 ＃ might already be defined<br />
delay_pools 1<br />
delay_class 1 1<br />
delay_access 1 allow all<br />
delay_parameters 1 64000/64000 ＃ 512 kbits == 64 kbytes per second<br />
2. 限制限制单一的带宽为 128 Kbps<br />
acl only128kusers src 192.168.1.0/255.255.192.0<br />
acl all src 0.0.0.0/0.0.0.0<br />
delay_pools 1<br />
delay_class 1 3<br />
delay_access 1 allow only128kusers<br />
delay_access 1 deny all<br />
delay_parameters 1 64000/64000 -1/-1 16000/64000<br />
3. 对某些特定的网站设置不通的带宽限制 (自己尝试一下,如果有错误请自行修改)<br />
acl lan_use src 192.168.1.0/255.255.255.0 ＃ 设置 LAN 使用者的 ACL<br />
acl kkbox dstdomain .kkbox.com.tw ＃ 设置特定域名的 ACL<br />
delay_pools 2 ＃设置两个 delay_pools<br />
delay_class 1 1 ＃ 第一个是 Class 1 的,用來限制总带宽<br />
delay_class 2 2 ＃ 第二个是 Class 2 的,用来限制单一的带宽<br />
delay_access 1 allow kkbox<br />
delay_access 1 deny all<br />
delay_access 2 allow lan_use<br />
delay_access 2 deny all<br />
delay_parameters 1 64000/64000 ＃ 不限制指定域名的单一带宽,但对总带宽速作限制<br />
delay_parameters 2 64000/64000 10000/50000 ＃ 限制 LAN 的所有使用者单一带宽,并对总的带宽作以限制
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/squid-%e4%bc%98%e5%8c%96/">squid 优化</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/squid-%e4%bc%98%e5%8c%96/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>squid 指定某个目录不做防盗链。</title>
		<link>http://www.apparitor.info/2011/04/06/squid-%e6%8c%87%e5%ae%9a%e6%9f%90%e4%b8%aa%e7%9b%ae%e5%bd%95%e4%b8%8d%e5%81%9a%e9%98%b2%e7%9b%97%e9%93%be%e3%80%82/</link>
		<comments>http://www.apparitor.info/2011/04/06/squid-%e6%8c%87%e5%ae%9a%e6%9f%90%e4%b8%aa%e7%9b%ae%e5%bd%95%e4%b8%8d%e5%81%9a%e9%98%b2%e7%9b%97%e9%93%be%e3%80%82/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 06:58:54 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Cache]]></category>
		<category><![CDATA[Squid]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=242</guid>
		<description><![CDATA[我有个图片的域名 www.imgtest.com 这里是我所有的域名下的图片。 以前这个www.imgtest.com在squid 上做的防盗链。 现在要求有一个域名test的图片不做防盗链。他在http://www.imgtest.com/test/这个目录下 解决： 在防盗链前加入 acl test url_regex -i http://www.imgtest.com/test/ http_access allow test # squid -k parse OK 问题解决 原创文章，转载请注明： 转载自gjw_apparitor 博客 本文链接地址: squid 指定某个目录不做防盗链。]]></description>
			<content:encoded><![CDATA[<p>我有个图片的域名 www.imgtest.com  这里是我所有的域名下的图片。<br />
以前这个www.imgtest.com在squid 上做的防盗链。</p>
<p>现在要求有一个域名test的图片不做防盗链。他在http://www.imgtest.com/test/这个目录下</p>
<p>解决：<br />
在防盗链前加入<br />
acl test url_regex -i http://www.imgtest.com/test/<br />
http_access allow test</p>
<p># squid -k parse  </p>
<p>OK 问题解决
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/squid-%e6%8c%87%e5%ae%9a%e6%9f%90%e4%b8%aa%e7%9b%ae%e5%bd%95%e4%b8%8d%e5%81%9a%e9%98%b2%e7%9b%97%e9%93%be%e3%80%82/">squid 指定某个目录不做防盗链。</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/squid-%e6%8c%87%e5%ae%9a%e6%9f%90%e4%b8%aa%e7%9b%ae%e5%bd%95%e4%b8%8d%e5%81%9a%e9%98%b2%e7%9b%97%e9%93%be%e3%80%82/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>squid 第三方插件squirm</title>
		<link>http://www.apparitor.info/2011/04/06/squid-%e7%ac%ac%e4%b8%89%e6%96%b9%e6%8f%92%e4%bb%b6squirm/</link>
		<comments>http://www.apparitor.info/2011/04/06/squid-%e7%ac%ac%e4%b8%89%e6%96%b9%e6%8f%92%e4%bb%b6squirm/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 06:50:53 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Cache]]></category>
		<category><![CDATA[Squid]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=231</guid>
		<description><![CDATA[squirm begin network 0.0.0.0/0 log logs/match.log abort-log logs/abort.log pattern squirm.patterns get #pattern common.patterns all end 原创文章，转载请注明： 转载自gjw_apparitor 博客 本文链接地址: squid 第三方插件squirm]]></description>
			<content:encoded><![CDATA[<p>squirm</p>
<p>begin<br />
network 0.0.0.0/0<br />
log logs/match.log<br />
abort-log logs/abort.log<br />
pattern squirm.patterns get<br />
#pattern common.patterns all<br />
end
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/squid-%e7%ac%ac%e4%b8%89%e6%96%b9%e6%8f%92%e4%bb%b6squirm/">squid 第三方插件squirm</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/squid-%e7%ac%ac%e4%b8%89%e6%96%b9%e6%8f%92%e4%bb%b6squirm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Squid封迅雷下载</title>
		<link>http://www.apparitor.info/2011/04/06/squid%e5%b0%81%e8%bf%85%e9%9b%b7%e4%b8%8b%e8%bd%bd/</link>
		<comments>http://www.apparitor.info/2011/04/06/squid%e5%b0%81%e8%bf%85%e9%9b%b7%e4%b8%8b%e8%bd%bd/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 06:50:01 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Cache]]></category>
		<category><![CDATA[Squid]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=229</guid>
		<description><![CDATA[# vi squid.conf acl Xunlei browser ^Mozilla/4\.0\s\(compatible;\sMSIE\s6\.0;Windows\sNT\s5\.1\)$http_access deny XunLei 迅雷每个版本的User Agent头都不一样，ACL还要增加。 原创文章，转载请注明： 转载自gjw_apparitor 博客 本文链接地址: Squid封迅雷下载]]></description>
			<content:encoded><![CDATA[<p># vi squid.conf<br />
acl Xunlei browser ^Mozilla/4\.0\s\(compatible;\sMSIE\s6\.0;Windows\sNT\s5\.1\)$http_access deny XunLei</p>
<p>迅雷每个版本的User Agent头都不一样，ACL还要增加。
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/04/06/squid%e5%b0%81%e8%bf%85%e9%9b%b7%e4%b8%8b%e8%bd%bd/">Squid封迅雷下载</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/04/06/squid%e5%b0%81%e8%bf%85%e9%9b%b7%e4%b8%8b%e8%bd%bd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TCmalloc对squid的性能的提升</title>
		<link>http://www.apparitor.info/2011/03/29/61/</link>
		<comments>http://www.apparitor.info/2011/03/29/61/#comments</comments>
		<pubDate>Tue, 29 Mar 2011 07:39:23 +0000</pubDate>
		<dc:creator>gjw_apparitor</dc:creator>
				<category><![CDATA[Cache]]></category>
		<category><![CDATA[Squid]]></category>

		<guid isPermaLink="false">http://www.apparitor.info/?p=61</guid>
		<description><![CDATA[TCmalloc对squid的性能的提升 一、简介： TCmalloc全称是Thread-Caching malloc，作者宣称tcmalloc相对于glibc2.3 malloc(aka ptmalloc2)有6倍的性能提高，tcmalloc的常用场景是用于加速MySQL，不过据Wikipedia的hacker Domas Mituzas说，tcmalloc不仅仅对MySQL起作用，对squid也同样起作用，不过目前正式版的squid并没有使用tcmalloc。 http://code.google.com/p/google-perftools/ 二、安装 1、安装tcmalloc所需要的libunwind库 [32位系统不用安装] # wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz # tar zxvf libunwind-0.99-alpha.tar.gz # cd libunwind-0.99-alpha # CFLAGS=-fPIC ./configure # make CFLAGS=-fPIC # make CFLAGS=-fPIC install 2、安装tcmalloc # wget http://google-perftools.googlecode.com/files/google-perftools-1.7.tar.gz # tar zxvf google-perftools-1.7.tar.gz # google-perftools-1.7 # ./configure # make # make install # echo '/usr/local/lib' &#62;&#62; /etc/ld.so.conf #]]></description>
			<content:encoded><![CDATA[<p>TCmalloc对squid的性能的提升</p>
<p>一、简介：</p>
<p>TCmalloc全称是Thread-Caching malloc，作者宣称tcmalloc相对于glibc2.3 malloc(aka ptmalloc2)有6倍的性能提高，tcmalloc的常用场景是用于加速MySQL，不过据Wikipedia的hacker Domas Mituzas说，tcmalloc不仅仅对MySQL起作用，对squid也同样起作用，不过目前正式版的squid并没有使用tcmalloc。</p>
<p>http://code.google.com/p/google-perftools/</p>
<p><span id="more-61"></span>二、安装</p>
<p>1、安装tcmalloc所需要的libunwind库 [32位系统不用安装]</p>
<pre># wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz
# tar zxvf libunwind-0.99-alpha.tar.gz
# cd libunwind-0.99-alpha
# CFLAGS=-fPIC ./configure
# make CFLAGS=-fPIC
# make CFLAGS=-fPIC install</pre>
<p>2、安装tcmalloc</p>
<pre># wget http://google-perftools.googlecode.com/files/google-perftools-1.7.tar.gz
# tar zxvf google-perftools-1.7.tar.gz
# google-perftools-1.7
# ./configure
# make
# make install
# echo '/usr/local/lib' &gt;&gt; /etc/ld.so.conf
# /sbin/ldconfig</pre>
<p>3、安装squid</p>
<pre># wget http://www.squid-cache.org/Versions/v2/2.7/squid-2.7.STABLE9.tar.gz
# tar zxvf squid-2.7.STABLE9.tar.gz
# cd squid-2.7.STABLE9
# ./configure --prefix=/usr/local/squid --enable-dlmalloc --enable-gnuregex --enable-async-io --enable-storeio=aufs,diskd,ufs --enable-arp-acl --disable-htcp --enable-snmp --enable-ssl --enable-large-cache-files --disable-internal-dns --enable-linux-netfilter --disable-ident-lookups --enable-truncate --with-maxfd=65535 --enable-forw-via-db --enable-referer-log --enable-useragent-log --enable-delay-pools --enable-kill-parent-hack --disable-carp --disable-icmp --enable-follow-x-forwarded-for --enable-default-err-language=Simplify_Chinese –enable-err-languages=Simplify_Chinese --enable-epoll</pre>
<p>*注意：据说加上&#8217;&#8211;with-large-files&#8217; 选项时编译会出错。<br />
# vi src/Makefile</p>

<div class="wp_codebox"><table><tr id="p612"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p61code2"><pre class="shell" style="font-family:monospace;">squid_LDADD = \
        -L../lib \
        -ltcmalloc_minimal \
         \
……
data_DATA = \
        mib.txt
LDADD = -L../lib -lmiscutil -lpthread -lm -ltcmalloc_minimal</pre></td></tr></table></div>

<p>//红色部分为新加的部分。保存退出。</p>
<pre># make &amp;&amp; make install</pre>
<p>4、配置好squid并启动squid.</p>
<p>&nbsp;</p>
<p>三、验证</p>
<pre># lsof | grep tcmalloc
squid 25548 root mem REG 8,3 872325 347206 /usr/local/lib/libtcmalloc_minimal.so.0.1.0
squid 25550 nobody mem REG 8,3 872325 347206 /usr/local/lib/libtcmalloc_minimal.so.0.1.0
dnsserver 25551 nobody mem REG 8,3 872325 347206 /usr/local/lib/libtcmalloc_minimal.so.0.1.0
dnsserver 25552 nobody mem REG 8,3 872325 347206 /usr/local/lib/libtcmalloc_minimal.so.0.1.0
dnsserver 25553 nobody mem REG 8,3 872325 347206 /usr/local/lib/libtcmalloc_minimal.so.0.1.0
dnsserver 25554 nobody mem REG 8,3 872325 347206 /usr/local/lib/libtcmalloc_minimal.so.0.1.0
dnsserver 25555 nobody mem REG 8,3 872325 347206 /usr/local/lib/libtcmalloc_minimal.so.0.1.0</pre>
<p>&nbsp;</p>
<p>四、压力测试</p>
<p>1、压力测试设备硬件<br />
squid+tcmalloc: 20 型号：Dell R410 硬盘：2*SAS/146G/15K 内存：16G CPU：16<br />
squid: 21 型号：Dell R410 硬盘：2*SAS/146G/15K 内存：16G CPU：16<br />
http_load: 23 型号：Dell R410 硬盘：2*SAS/146G/15K 内存：16G CPU：16<br />
http_load: 24 型号：Dell R410 硬盘：2*SAS/146G/15K 内存：16G CPU：16</p>
<p>&nbsp;</p>
<p>2、压力测试<br />
a、使用http_load压测软件。<br />
b、参数：./http_load -parallel 1000 -fetches 72000000 -proxy $IP:80 1.txt<br />
c、2台压力测试机同时对2台squid做压力测试，测试url约 15万条左右。<br />
d、参考cacti里对应该设备的各项系统性能值。<br />
f、参考http_load压测结果。</p>
<p style="padding-left: 30px;">&nbsp;</p>
<p>五、结果</p>
<p>1、cacti里数据图</p>
<p>安装tcmalloc的squid:</p>
<p><span style="font-size: xx-small;"><a href="http://www.apparitor.info/wp-content/uploads/2011/03/liulinag-20.png"><img class="alignnone size-medium wp-image-86" title="liulinag-20" src="http://www.apparitor.info/wp-content/uploads/2011/03/liulinag-20-300x132.png" alt="" width="300" height="132" /></a></span></p>
<p><a href="http://www.apparitor.info/wp-content/uploads/2011/03/cpu-20.png"><img class="alignnone size-medium wp-image-88" title="cpu-20" src="http://www.apparitor.info/wp-content/uploads/2011/03/cpu-20-300x151.png" alt="" width="300" height="151" /></a><a href="http://www.apparitor.info/wp-content/uploads/2011/03/load-20.png"><img class="alignnone size-medium wp-image-84" title="load-20" src="http://www.apparitor.info/wp-content/uploads/2011/03/load-20-300x149.png" alt="" width="300" height="149" /></a></p>
<p>使用默认malloc的squid:</p>
<p><a href="http://www.apparitor.info/wp-content/uploads/2011/03/liulinag-21.png"><img class="alignnone size-medium wp-image-85" title="liulinag-21" src="http://www.apparitor.info/wp-content/uploads/2011/03/liulinag-21-300x133.png" alt="" width="300" height="133" /></a></p>
<p><a href="http://www.apparitor.info/wp-content/uploads/2011/03/liulinag-21.png"></a><a href="http://www.apparitor.info/wp-content/uploads/2011/03/cpu-21.png"><img class="alignnone size-medium wp-image-87" title="cpu-21" src="http://www.apparitor.info/wp-content/uploads/2011/03/cpu-21-300x150.png" alt="" width="300" height="150" /></a><a href="http://www.apparitor.info/wp-content/uploads/2011/03/load-21.png"><img class="alignnone size-medium wp-image-83" title="load-21" src="http://www.apparitor.info/wp-content/uploads/2011/03/load-21-300x151.png" alt="" width="300" height="151" /></a></p>
<p>&nbsp;</p>
<p>2、http_load 数据</p>
<p>tcmalloc:</p>
<pre>72000000 fetches, 1000 max parallel, 8.7075e+11 bytes, in 9468.61 seconds
12093.7 mean bytes/connection
7604.07 fetches/sec, 9.19617e+07 bytes/sec
msecs/connect: 105.061 mean, 45012.3 max, 0.057 min
msecs/first-response: 21.9229 mean, 12735.5 max, 0.147 min
78 timeouts
4713 bad byte counts
HTTP response codes:
  code 200 -- 71966231
  code 404 -- 33691</pre>
<p>malloc:</p>
<pre>72000000 fetches, 1000 max parallel, 8.68734e+11 bytes, in 11421.9 seconds
12065.8 mean bytes/connection
6303.66 fetches/sec, 7.60584e+07 bytes/sec
msecs/connect: 127.434 mean, 45004.9 max, 0.05 min
msecs/first-response: 25.8337 mean, 25654.4 max, 0.154 min
454 timeouts
15137051 bad byte counts
HTTP response codes:
  code 200 -- 71777915
  code 404 -- 33825</pre>
<p>3、squid里mgr:info数据<br />
tcmalloc:</p>
<pre>Request Hit Ratios:	5min: 100.0%, 60min: 99.3%
Byte Hit Ratios:	5min: 99.4%, 60min: 98.8%
Request Memory Hit Ratios:	5min: 100.0%, 60min: 100.0%
Request Disk Hit Ratios:	5min: 0.0%, 60min: 0.0%</pre>
<p>malloc:</p>
<pre>Request Hit Ratios:	5min: 100.0%, 60min: 99.8%
Byte Hit Ratios:	5min: 99.5%, 60min: 99.1%
Request Memory Hit Ratios:	5min: 23.5%, 60min: 23.4%
Request Disk Hit Ratios:	5min: 76.5%, 60min: 76.6%</pre>
<p>&nbsp;</p>
<p>六、分析</p>
<p>1、从cacti的数据图可以看出使用tcmalloc的squid，并发性能更加稳定，从出口流量可以看出基本稳定在 795Mb/s</p>
<p>2、从http_load的结果来看，tcmalloc的每秒处理的请求更多，bad byte counts 要少很多。</p>
<p>3、从squid的mgr:info来看，命中率都很高，要注意的是tcmalloc的命中全部是在内存上的。这点提升了他的性能。</p>
<p>&nbsp;
<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://www.apparitor.info/">gjw_apparitor 博客</a></p>
<p><strong>本文链接地址:</strong> <a href="http://www.apparitor.info/2011/03/29/61/">TCmalloc对squid的性能的提升</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.apparitor.info/2011/03/29/61/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

