高性能反向代理Apache Traffic Server配置小记 [ats cdn cache]



简单介绍下啥是ats?


Apache Traffic ServerATSTS)是一个高性能的、模块化的

HTTP 代理和缓存服务器。



谁再用?


淘宝,京东,蓝讯,雅虎等都在搞。


为啥用?

天生的多进程,epoll高性能框架,强大的cli功能,能把要缓存的大文件直接push进缓存系统给里面等等。。。


不扯了,直接干起。。。


下载地址:

http://apache.fayea.com/apache-mirror/trafficserver/


配置环境

1
yum install make gcc gcc-c++ glibc-devel db4-devel openssl-devel tcl-devel expat-devel pcre-devel -y


解压安装:

1
2
3
./configure --prefix=/usr/local/ats && make && make install
make
make install


005055470.jpg

主要的配置文件:

1
2
3
records.config 是 key-value 格式的配置文件,负责大部分全局的选项设置,即主配置文件。
storage.config 用于指定磁盘存储。
remap.config   定义映射规则,用于请求的重写(rewrite),反向代理即在此配置


records.config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
records.config文件:
CONFIGproxy.config.exec_thread.autoconfig INT  1
CONFIG proxy.config.exec_thread.autoconfig.scale FLOAT2. 0
CONFIG proxy.config.exec_thread.limit INT2   #经观察是每个核创建的线程数,官方文档中未提及
                                                                                                                                                                                                                                                      
CONFIG proxy.config.cluster.ethernet_interface STRING eth0 # 设置以太网接口
CONFIG proxy.config.http.server_port  INT  8080   # 监听端口,反向代理通常为 80
LOCAL proxy.local.incoming_ip_to_bind STRING   0.0 . 0.0 # 绑定的 IP,可省略,默认即为  0.0 . 0.0
                                                                                                                                                                                                                                                      
CONFIG proxy.config.http.cache.http INT  1  #打开缓存功能
CONFIG proxy.config.cache.ram_cache.size INT 512M  # RAM 缓存大小
                                                                                                                                                                                                                                                      
CONFIG proxy.config.reverse_proxy.enabled INT  1    # 打开
CONFIG proxy.config.url_remap.remap_required INT  1  # 1 为只反向代理, 0 为正向+反向代理
CONFIG proxy.config.url_remap.pristine_host_hdr INT  0
CONFIG proxy.config.ssl.enabled INT  0  #关闭SSL
CONFIG proxy.config.ssl.server.cert.filename STRING server.pem
CONFIG proxy.config.http.server_max_connections INT  2000   # 同源服务器的最大连接数
CONFIG proxy.config.http.keep_alive_no_activity_timeout_out INT  60  # 当一个事务结束后同原服务器保持连接的时间


remap.config

第一个用户访问163.com 第二个是 ats自动去访问163.com取源,当然也可以是ip地址

1
map    http: //www.163.com  http://www.163.com



storage.config

cache目录定义文件

淘宝最新出的一个版本有一个专门的stotage_ssd.config配置文件针对ssd盘的


格式为目录 大小


1
/data/cache1 20GB


ats的执行程序 ~

010029696.jpg


1
2
3
4
5
6
./traffic_line -r proxy.node.cache_hit_ratio_avg_10s #查询当前缓存服务命中率
./traffic_line -r proxy.node.current_server_connections #到后端源的连接数
./traffic_line -r proxy.node.current_client_connections #前端用户到TServer的连接数
./traffic_line -r proxy.node.user_agent_xacts_per_second #平均每秒处理的并发数
./traffic_line -r proxy.node.client_throughput_out #当前TServer输出到前端的带宽流量(单位Mbps)
./traffic_line -L#在不重启服务的情况下,使新配置生效,单结点模式,也有集群模式,注意看--help


服务控制


1
2
3
运行 /usr/local/bin/trafficserver start
结束 /usr/local/bin/trafficserver stop
重启 /usr/local/bin/trafficserver restart



忽然发现自己,有段时间没有搞运维了~  感觉现在越来越开发了 ~


我会继续更新ats cdn的方面的总结文档的~

更新中~



 本文转自 rfyiamcool 51CTO博客,原文链接:http://blog.51cto.com/rfyiamcool/1319479,如需转载请自行联系原作者



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值