正向代理服务器软件(Tinyproxy、Apache Traffic Server、Squid Cache)压测

  sre


本文选取了三种常见的正向代理服务器软件(Tinyproxy、Apache Traffic Server、Squid Cache),通过压力测试对三种代理软件在吞吐量、高并发等性能方面进行了对比与分析。内容共分为三个部分,首先介绍三类代理软件以及安装过程,然后讲述压力测试客户端程序的原理与使用说明,最后,就实验数据进行分析并得出结论。
Apache Traffic Server

简介

Apache Traffic Server(简称Apache TS)是一个高性能的、模块化的HTTP代理和缓存服务器,同时支持HTTP/HTTPS的正向代理与反向代理,具有如下特点:
缓存:改进响应时间的同时降低了服务器负载与对带宽的需求,这是通过缓存并且重用经常请求的网页、图片和Web Service调用实现的。
代理:很容易添加持续连接、过滤器或异步内容请求,还可以通过添加代理层实现负载平衡。
速度:在现代的SMP硬件上具有很好的可伸缩性,每秒钟可以处理数以万计的请求。可扩展性:API考虑到了自定义插件,可以修改头与内容,还可以实现新的协议处理器。
可靠性:能够完美处理TB级别的数据,包括正向与反向代理。
Apache Traffic Server v.3.0.0基准测试的结果是每秒钟可以处理200,000多个请求,相对于v2.0来说提升了277%。它可以用在各种大规模的产品部署环境中,Yahoo!使用Apache Traffic Server处理400TB的数据量,同时每天还使用它处理多达300亿的数据对象,包括Yahoo!主页、体育、邮件及财经站点。

安装及配置

1.安装配置EPEL 源
~]wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-1.noarch.rpm
~] sudo rpm -Uvh epel-release-7*.rpm
2.安装Apache Traffic Server
~]sudo yum install trafficserver
3.修改配置(/etc/trafficserver/records.config),按照下面修改相应配置项
# disable the reverse proxying
CONFIG proxy.config.reverse_proxy.enabled INT 0
CONFIG proxy.config.url_remap.remap_required INT 0
# shutdown http cache
CONFIG proxy.config.http.cache.http INT 0
4.运行(默认端口3128)
~] /usr/bin/trafficserver start
Squid Cache

简介
Squid Cache(简称Squid)是一个高性能的代理缓存服务器,可以加快内部网浏览 Internet的速度,提高客户机的访问命中率。Squid不仅支持HTTP协议,还支持FTP、gopher、SSL和WAIS等协议。和一般的代理 缓存软件不同,Squid用一个单独的、非模块化的、I/O驱动的进程来处理所有的客户端请求。
Squid将数据元缓存在内存中,同时也缓存DNS查寻的结果,除此之外,它还支持非模块化的DNS查询,对失败的请求进行消极缓存。Squid支持SSL,支持访问控制。由于使用了ICP,Squid能够实现重叠的代理阵列,从而最大限度的节约带宽。
Squid由一个主要的服务程序Squid,一个DNS查询程序 dnsserver,几个重写请求和执行认证的程序,以及几个管理工具组成。当Squid启动以后,它可以派生出指定数目的dnsserver进程,而每 一个dnsserver进程都可以执行单独的DNS查询,这样一来就大大减少了服务器等待DNS查询的时间。
Squid的另一个优越性在于它使用访问控制清单(ACL)和访问权限清单(ARL)。访问控制清单和访问权限清单通过阻止特定的网络连接来减少潜在的Internet非法连接,可以使用这些清单来确保内部网的主机无法访问有威胁的或不适宜的站点。
安装及配置

1.安装Squid
~]sudo yum install -y squid
2.修改配置文件(/etc/squid/squid.conf):
#cache_dir ufs /var/spool/squid 1024 16 256
cache deny all  #禁用缓存
3.运行(默认端口3128)
~] service squid start

Tinyproxy
简介
Tinyproxy是一个轻量级的开源web代理守护进程,其设计目标是快而小。它适用于需要完整HTTP代理特性,但系统资源又不足以运行大型代理的场景,比如嵌入式部署。
Tinyproxy对小规模网络非常有用,这样的场合下大型代理会使系统资源紧张,或有安全风险。Tinyproxy的一个关键特性是其缓冲连接的理念。从效果上看,Tinyproxy 对服务器的响应进行了高速缓冲,然后按照客户端能够处理的最高速度进行响应。该特性极大的降低了网络延滞带来的问题。
安装及配置

1.安装tinyproxy
~]sudo yum -y install tinyproxy
2.修改配置文件(/etc/tinyproxy/tinyproxy.conf),增加如下配置
Allow 192.168.0.0/16  #配置自己的IP地址
3.运行(默认端口8888)
~] service tinyproxy start

压测客户端程序
程序原理

1)通过命令行运行
2)命令参数合法性校验, host必须为合法IP地址,port端口范围0~65535,
loops为发送请求数,范围为1~Integer.MAX_VALUE,threads为并发线程数,范围1~1000.
3)若参数合法,则创建http/s client
4)创建线程池
5)发送请求,同时记录日志
6)统计测试数据。
编译、运行
1.编译、打包(确保正确安装maven插件,可参考:https://maven.apache.org/install.html)
~]$ mvn clean package
2.用法如下图所示:

实验结论
测试环境
Squid Cache: Version 3.5.20
Tinyproxy 1.8.3
Apache Traffic Server 5.3.0
并发线程数为16、32、64运行1核1g
并发线程为128时运行4核1g
Ps:并发较高时,受限于主机资源,尤其是CPU占用率,请求失败率上升

分析结果

测试数据如上图所示,综合性能方面Squid cache表现最好,tinyproxy表现最差,Apache traffic server居中;当并发量进一步上升,Apache traffic server的性能逐渐接近于squid。

附录:

Apache Traffic Server=
-path http://www.kyeegroup.com/#/home ^
-host 192.168.52.128 ^
-port 8080 ^
-threads 16 ^
-loops 10000

【01】success:10000, fail:0, avg time:13.621ms, failure rate:0.00% x
【02】success:10000, fail:0, avg time:16.430ms, failure rate:0.00%
【03】success:10000, fail:0, avg time:32.523ms, failure rate:0.00%
【04】success:10000, fail:0, avg time:38.736ms, failure rate:0.00% x
【05】success:10000, fail:0, avg time:27.232ms, failure rate:0.00%
【06】success:10000, fail:0, avg time:14.224ms, failure rate:0.00%
【07】success:10000, fail:0, avg time:15.024ms, failure rate:0.00%
【08】success:10000, fail:0, avg time:16.549ms, failure rate:0.00%
【09】success:9851, fail:149, avg time:19.316ms, failure rate:1.49%
【10】success:10000, fail:0, avg time:14.720ms, failure rate:0.00%
【11】success:10000, fail:0, avg time:15.217ms, failure rate:0.00%
【12】success:10000, fail:0, avg time:14.716ms, failure rate:0.00%

-path http://www.kyeegroup.com/#/home ^
-host 192.168.52.128 ^
-port 8080 ^
-threads 32 ^
-loops 10000

【01】success:10000, fail:0, avg time:7.228ms, failure rate:0.00%
【02】success:10000, fail:0, avg time:6.717ms, failure rate:0.00%
【03】success:10000, fail:0, avg time:8.821ms, failure rate:0.00%
【04】success:10000, fail:0, avg time:7.313ms, failure rate:0.00%
【05】success:10000, fail:0, avg time:7.319ms, failure rate:0.00%
【06】success:10000, fail:0, avg time:8.015ms, failure rate:0.00%
【07】success:10000, fail:0, avg time:6.319ms, failure rate:0.00%
【08】success:10000, fail:0, avg time:7.220ms, failure rate:0.00%
【09】success:10000, fail:0, avg time:7.915ms, failure rate:0.00%
【10】success:10000, fail:0, avg time:5.821ms, failure rate:0.00% x
【11】success:10000, fail:0, avg time:7.313ms, failure rate:0.00%
【12】success:10000, fail:0, avg time:9.917ms, failure rate:0.00% x

-path http://www.kyeegroup.com/#/home ^
-host 192.168.52.128 ^
-port 8080 ^
-threads 64 ^
-loops 10000

【01】success:10000, fail:0, avg time:5.617ms, failure rate:0.00%
【02】success:9364, fail:636, avg time:5.915ms, failure rate:6.36%
【03】success:8744, fail:1256, avg time:5.226ms, failure rate:12.56%
【04】success:10000, fail:0, avg time:3.213ms, failure rate:0.00% x
【05】success:9134, fail:866, avg time:5.128ms, failure rate:8.66%
【06】success:10000, fail:0, avg time:4.016ms, failure rate:0.00%
【07】success:10000, fail:0, avg time:6.617ms, failure rate:0.00%
【08】success:10000, fail:0, avg time:7.316ms, failure rate:0.00% x
【09】success:10000, fail:0, avg time:6.015ms, failure rate:0.00%
【10】success:9158, fail:842, avg time:7.134ms, failure rate:8.42%
【11】success:10000, fail:0, avg time:4.317ms, failure rate:0.00%
【12】success:10000, fail:0, avg time:3.713ms, failure rate:0.00%

= Squid
-path http://www.kyeegroup.com/#/home ^
-host 192.168.52.128 ^
-port 3128 ^
-threads 16 ^
-loops 10000

【01】success:10000, fail:0, avg time:2.711ms, failure rate:0.00%
【02】success:10000, fail:0, avg time:2.410ms, failure rate:0.00%
【03】success:9932, fail:68, avg time:2.719ms, failure rate:0.68%
【04】success:9940, fail:60, avg time:2.510ms, failure rate:0.60%
【05】success:9934, fail:66, avg time:2.616ms, failure rate:0.66%
【06】success:10000, fail:0, avg time:2.412ms, failure rate:0.00%
【07】success:9999, fail:1, avg time:2.414ms, failure rate:0.01%
【08】success:10000, fail:0, avg time:2.410ms, failure rate:0.00%
【09】success:9996, fail:4, avg time:2.513ms, failure rate:0.04%
【10】success:10000, fail:0, avg time:2.731ms, failure rate:0.00%
【11】success:10000, fail:0, avg time:2.310ms, failure rate:0.00% x
【12】success:9506, fail:494, avg time:3.222ms, failure rate:4.94% x

-path http://www.kyeegroup.com/#/home ^
-host 192.168.52.128 ^
-port 3128 ^
-threads 32 ^
-loops 10000

【01】success:10000, fail:0, avg time:2.713ms, failure rate:0.00%
【02】success:10000, fail:0, avg time:2.513ms, failure rate:0.00%
【03】success:10000, fail:0, avg time:2.712ms, failure rate:0.00%
【04】success:10000, fail:0, avg time:2.426ms, failure rate:0.00%
【05】success:10000, fail:0, avg time:2.614ms, failure rate:0.00%
【06】success:10000, fail:0, avg time:2.413ms, failure rate:0.00% x
【07】success:10000, fail:0, avg time:2.722ms, failure rate:0.00%
【08】success:10000, fail:0, avg time:2.417ms, failure rate:0.00%
【09】success:9959, fail:41, avg time:2.615ms, failure rate:0.41%
【10】success:9997, fail:3, avg time:2.413ms, failure rate:0.03%
【11】success:9837, fail:163, avg time:3.038ms, failure rate:1.63% x
【12】success:10000, fail:0, avg time:2.711ms, failure rate:0.00%

-path http://www.kyeegroup.com/#/home ^
-host 192.168.52.128 ^
-port 3128 ^
-threads 64 ^
-loops 10000

【01】success:9845, fail:155, avg time:2.514ms, failure rate:1.55%
【02】success:9997, fail:3, avg time:2.413ms, failure rate:0.03% x
【03】success:9844, fail:156, avg time:2.635ms, failure rate:1.56%
【04】success:10000, fail:0, avg time:2.612ms, failure rate:0.00%
【05】success:10000, fail:0, avg time:2.614ms, failure rate:0.00%
【06】success:10000, fail:0, avg time:2.812ms, failure rate:0.00%
【07】success:10000, fail:0, avg time:2.719ms, failure rate:0.00%
【08】success:10000, fail:0, avg time:2.821ms, failure rate:0.00%
【09】success:9995, fail:5, avg time:2.713ms, failure rate:0.05%
【10】success:9997, fail:3, avg time:2.614ms, failure rate:0.03%
【11】success:10000, fail:0, avg time:2.622ms, failure rate:0.00%
【12】success:8851, fail:1149, avg time:3.286ms, failure rate:11.49% x

Tinyproxy =
-path http://www.kyeegroup.com/#/home ^
-host 192.168.52.128 ^
-port 8888 ^
-threads 16 ^
-loops 10000

【01】success:10000, fail:0, avg time:30.842ms, failure rate:0.00%
【02】success:10000, fail:0, avg time:23.727ms, failure rate:0.00%
【03】success:10000, fail:0, avg time:25.432ms, failure rate:0.00%
【04】success:10000, fail:0, avg time:38.066ms, failure rate:0.00% x
【05】success:10000, fail:0, avg time:27.931ms, failure rate:0.00%
【06】success:10000, fail:0, avg time:28.770ms, failure rate:0.00%
【07】success:10000, fail:0, avg time:36.636ms, failure rate:0.00% 
【08】success:10000, fail:0, avg time:23.027ms, failure rate:0.00%
【09】success:10000, fail:0, avg time:25.528ms, failure rate:0.00%
【10】success:10000, fail:0, avg time:21.531ms, failure rate:0.00% x
【11】success:10000, fail:0, avg time:27.030ms, failure rate:0.00%
【12】success:10000, fail:0, avg time:23.035ms, failure rate:0.00%

-path http://www.kyeegroup.com/#/home ^
-host 192.168.52.128 ^
-port 8888 ^
-threads 32 ^
-loops 10000

【01】success:10000, fail:0, avg time:22.827ms, failure rate:0.00%   
【02】success:10000, fail:0, avg time:20.323ms, failure rate:0.00%
【03】success:10000, fail:0, avg time:19.020ms, failure rate:0.00%
【04】success:10000, fail:0, avg time:20.826ms, failure rate:0.00%
【05】success:10000, fail:0, avg time:18.421ms, failure rate:0.00%
【06】success:10000, fail:0, avg time:18.524ms, failure rate:0.00%
【07】success:10000, fail:0, avg time:18.734ms, failure rate:0.00%
【08】success:10000, fail:0, avg time:18.730ms, failure rate:0.00%
【09】success:10000, fail:0, avg time:21.423ms, failure rate:0.00% 
【10】success:10000, fail:0, avg time:32.748ms, failure rate:0.00% x
【11】success:10000, fail:0, avg time:16.424ms, failure rate:0.00% x
【12】success:10000, fail:0, avg time:17.123ms, failure rate:0.00%

-path http://www.kyeegroup.com/#/home ^
-host 192.168.52.128 ^
-port 8888 ^
-threads 64 ^
-loops 10000

【01】success:10000, fail:0, avg time:16.428ms, failure rate:0.00%
【02】success:10000, fail:0, avg time:18.124ms, failure rate:0.00%
【03】success:10000, fail:0, avg time:17.525ms, failure rate:0.00%
【04】success:10000, fail:0, avg time:18.338ms, failure rate:0.00%
【05】success:10000, fail:0, avg time:22.329ms, failure rate:0.00%  x
【06】success:10000, fail:0, avg time:21.131ms, failure rate:0.00%
【07】success:10000, fail:0, avg time:15.521ms, failure rate:0.00%  x
【08】success:10000, fail:0, avg time:22.760ms, failure rate:0.00%
【09】success:10000, fail:0, avg time:16.219ms, failure rate:0.00%
【10】success:10000, fail:0, avg time:17.824ms, failure rate:0.00%
【11】success:10000, fail:0, avg time:20.225ms, failure rate:0.00%
【12】success:10000, fail:0, avg time:15.522ms, failure rate:0.00%


4核1g 128threads

ApacheTS
【01】success:10000, fail:0, avg time:3.135ms, failure rate:0.00%
【02】success:10000, fail:0, avg time:3.335ms, failure rate:0.00%
【03】success:10000, fail:0, avg time:4.041ms, failure rate:0.00%
Squid
【01】success:10000, fail:0, avg time:2.127ms, failure rate:0.00%
【02】success:10000, fail:0, avg time:2.018ms, failure rate:0.00%
【03】success:10000, fail:0, avg time:2.017ms, failure rate:0.00%
Tinyproxy
【01】success:10000, fail:0, avg time:21.346ms, failure rate:0.00%
【02】success:10000, fail:0, avg time:20.450ms, failure rate:0.00%
【03】success:10000, fail:0, avg time:18.638ms, failure rate:0.00%

参考:
Apache ts
https://docs.trafficserver.apache.org/en/5.3.x/admin/forward-proxy.en.html
Tinyproxy

How to install and configure Tinyproxy on Ubuntu 14.04


Squid
http://wiki.squid-cache.org/SquidFaq/InstallingSquid/

LEAVE A COMMENT

Captcha Code