1 / 41

TCPCopy

TCPCopy. 王斌 ( http://weibo.com/tcpcopy ) 网易北京技术部 2012-04-09. 可用性. 可使用性. 可测试性. 可修改性. 性能. 安全性. 系统架构. 系统架构. 系统架构. 可用性. 可用性. 可用性. 可使用性. 可使用性. 可使用性. 可测试性. 可测试性. 可测试性. 可修改性. 可修改性. 可修改性. 性能. 性能. 性能. 安全. 安全. 安全. 可用性. 可用性. 可用性. 可用性. 可使用性. 系统架构. 可测试性. 可测试性. 可修改性. 可修改性.

barid
Télécharger la présentation

TCPCopy

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TCPCopy 王斌(http://weibo.com/tcpcopy) 网易北京技术部 2012-04-09

  2. 可用性 可使用性 可测试性 可修改性 性能 安全性 系统架构 系统架构

  3. 系统架构 可用性 可用性 可用性 可使用性 可使用性 可使用性 可测试性 可测试性 可测试性 可修改性 可修改性 可修改性 性能 性能 性能 安全 安全 安全 可用性 可用性 可用性 可用性 可使用性 系统架构 可测试性 可测试性 可修改性 可修改性 可修改性 可修改性 性能 性能 性能 安全性

  4. 我们常常遇到的架构问题 可测试性问题? 上线前,满怀信心;上线后,系统崩溃 性能问题? 到底nginx比apache快多少? 可用性问题? 服务器崩溃了,会不会发生雪崩? 可修改问题? 程序更新后,心惊胆战?

  5. 肿么办??? TCPCopy 网易技术部开发的开源产品

  6. 内容 开发TCPCopy的背景 定义 基础知识 TCPCopy详细介绍 实战 未来展望

  7. 开发TCPCopy的背景 网易广告投放系统 测试上线可能存在的问题 membase替换memcached 可用性试验 性能

  8. TCPCopy定义 一种基于底层的在线请求复制工具,可以用来解决架构方面的多种问题

  9. TCPCopy定义 通俗地讲,在不影响在线使用的情况下,把线上的流量复制并且引到测试环境中去

  10. 基础知识 TCP/IP protocol Linux Kernel RawSocket Netfilter/iptables Netlink

  11. TCP/IP protocol

  12. TCP/IP protocol • TCP • Sliding window protocol • Retransmission • Resequence • IP • IPfragmentation • DataLink

  13. Linux Kernel

  14. Raw Socket • 解决抓包问题 • 从数据链路层抓数据包 • 从IP层抓数据包 • 学习资料 http://sock-raw.org/papers/sock_raw • 抓包函数分析 http://blog.csdn.net/wangbin579/article/details/7312966

  15. Raw Socket User land Application Socket interface Snoop Application TCP/UDP processing Raw socket IP processing Snoop here Snoop here Data link processing

  16. Netfilter/iptables Firewall accepted incoming packets Internal processes of system INPUT chain packets to forward FORWARD chain accepted outgoing packets OUTPUT chain accepted packetes killed dropped/rejected System with netfilter/iptables

  17. Netlink A socket-like mechanism for IPC between the kernel and user space processes Only supported in linux 为啥要用netlink? 在响应包丢弃之前,截获响应包头信息 参考资料 Understanding And Programming With Netlink Sockets

  18. TCPCopy详细介绍 基本原理 架构 请求转发引擎 功能 特点 应用领域 如何使用 高级使用说明

  19. 基本原理 简单地说就是欺骗 详细地说,在在线服务器内抓在线数据包,想尽办法修改在线数据包并发送给测试服务器,以达到欺骗测试服务器的目的

  20. 基本原理 test machine Online machine TCP IP Data Link 假设在线是apache 应用 假设测试nginx 应用 nginx apache interception tcpcopy tcpcopy client TCP IP Data Link tcpcopy server online

  21. 基本原理 test machine Online machine nginx interception TCP IP Data Link apache tcpcopy Hello, darling header Hello,baby TCP IP drop /hello syn ack Data Link syn ack /hello

  22. TCPCopy架构 request replicated request response Communicaton tcpcopy server tcpcopy client

  23. TCPCopy Client User land application Route info TCP socket (communication) Socket interface Raw socket (input) TCPCopy client TCP/UDP processing Raw socket (output by sendto) Snoop here IP processing Replicated packets Data link processing

  24. TCPCopy Server User land application TCP socket (communication) Route info TCPCopy server Socket interface Replicated TCP/IP header Netlink socket (input) TCP/UDP processing drop IP Queue (interceptedport) IP processing Data link processing

  25. 请求转发引擎---包特点 一个TCP连接有一个或者多个请求 一个请求由一个或者多个包组成 请求包之间的延迟不一 请求包无序问题 包重传 抓包函数本身会存在丢包

  26. 请求转发引擎---如何传递packets 只传递合适的缓存packets给测试机器 适当补充必要的packets,以解决tcp交互过程中遇到的问题 充分利用滑动窗口的特点,解决访问量特别高的场合

  27. 请求转发引擎---代码框架 Packetprocessing diagram

  28. 功能 分布式压力测试工具 热备份 普通上线测试 性能对比试验 比如apache vs nginx 架构实战演习

  29. 特点 实时 效果真实 低负载,不影响在线 操作简单 分布式

  30. 应用领域 无状态的基于tcp的协议 Http协议 memcached protocol … 特殊有状态的协议 E.g. Mysql protocol

  31. 如何使用 准备阶段 下载代码 (svn checkout http://tcpcopy.googlecode.com/svn/trunk/ tcpcopy) ./configure make make install 运行阶段 测试机器 (root权限) modprobe ip_queue (if not running) iptables -I OUTPUT -p tcp --sport port -j QUEUE (if not set) ./interception 在线机器 (root权限) ./tcpcopy local_ip1[local_ip2:…]  local_port  remote_ip  remote_port

  32. 高级使用说明 通过代理,实现多重复制,使流量增倍 把请求复制到不同的代理,通过代理再走向待测试的程序 使用级联,增加在线流量 在测试机器上再复制流量到新的测试服务器上,可以增加测试服务器的数量,从而增加后端系统的压力

  33. 代理 代理A 在线 待测试机器 代理B

  34. 级联 中间业务服务器 在线 测试机器A 测试机器B

  35. 实战 Apache 2.4 vs nginx 的性能对比 网易广告投放系统

  36. nginx vs apache2.4 Apache 2.4宣称性能超过nginx,我们验证的结果是被nginx完爆 参考文档下载地址: http://tcpcopy.googlecode.com/files/nginx_pk_apache_2.4.pdf

  37. 广告投放系统 Http 广告请求 复制web请求 adclient集群 (nginx模块) 复制类似于memcached 协议的请求 adserver集群 复制后端请求 userserver

  38. 广告投放系统--- Nginx Nginx cpu 100% http://blog.csdn.net/wangbin579/article/details/6995456 Nginx升级问题 http://blog.csdn.net/wangbin579/article/details/7360662

  39. 广告投放系统--- OpenResty iconv-nginx-module http://blog.csdn.net/wangbin579/article/details/7197862 使用其模块后,发现cpu负载高了一倍 ngx-lua-module 正在测试中,还没有发现问题

  40. 未来展望 解决TCPCopy应用过程中遇到的问题 发现流行开源软件的bug 高并发情况 跟淘宝Tengine合作 性能评测 推向国际化 力争成为市面上压力测试工具的一员 代码重构,使其更加易读,易扩展

  41. 谢谢!http://weibo.com/tcpcopy

More Related