# Tcpcopy,an online request replication tool fit for nginx

**URL:** <https://www.ruby-forum.com/t/tcpcopy-an-online-request-replication-tool-fit-for-nginx/213440>\
**Category:** NGINX\
**Created:** [November 2, 2011, 7:21am UTC](https://www.ruby-forum.com/t/tcpcopy-an-online-request-replication-tool-fit-for-nginx/213440 "2011-11-02T07:21:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [November 2, 2011, 7:21am UTC](https://www.ruby-forum.com/t/tcpcopy-an-online-request-replication-tool-fit-for-nginx/213440/1 "2011-11-02T07:21:57Z")

</div>

Tcpcopy is an online request replication tool .  
It may be useful for migrating to nginx from apache

[GitHub - wangbin579/tcpcopy: An online request replication tool, also a tcp stream replay tool, fit for real testing, performance testing, stability testing, stress testing, load testing, smoke testing, etc](https://github.com/wangbin579/tcpcopy) or  
[Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/tcpcopy/)

Posted at Nginx Forum:

> **[Tcpcopy,an online request replication tool fit for nginx](https://forum.nginx.org/read.php?2,217680,217680#msg-217680)**
>
> Tcpcopy is an online request replication tool . It may be useful for migrating to nginx from apache https://github.com/wangbin579/tcpcopy or http://code.google.com/p/tcpcopy/

---

<div class="post-metadata">

**Author:** ![wangbin579](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bc79bd/32.png) [@wangbin579](https://www.ruby-forum.com/u/wangbin579)\
**Post date:** [November 2, 2011, 7:35am UTC](https://www.ruby-forum.com/t/tcpcopy-an-online-request-replication-tool-fit-for-nginx/213440/2 "2011-11-02T07:35:32Z")

</div>

you can use tcpcopy to compare the performances of apache and nginx.

Posted at Nginx Forum:

> **[Re: Tcpcopy,an online request replication tool fit for nginx](https://forum.nginx.org/read.php?2,217680,217682#msg-217682)**
>
> Tcpcopy is an online request replication tool . It may be useful for migrating to nginx from apache https://github.com/wangbin579/tcpcopy or http://code.google.com/p/tcpcopy/

---

<div class="post-metadata">

**Author:** ![wangbin579](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bc79bd/32.png) [@wangbin579](https://www.ruby-forum.com/u/wangbin579)\
**Post date:** [November 2, 2011, 7:57am UTC](https://www.ruby-forum.com/t/tcpcopy-an-online-request-replication-tool-fit-for-nginx/213440/3 "2011-11-02T07:57:07Z")

</div>

tcpcopy helps me a lot when deveploping the netease ad system and other  
systems

Posted at Nginx Forum:

> **[Re: Tcpcopy,an online request replication tool fit for nginx](https://forum.nginx.org/read.php?2,217680,217684#msg-217684)**
>
> Tcpcopy is an online request replication tool . It may be useful for migrating to nginx from apache https://github.com/wangbin579/tcpcopy or http://code.google.com/p/tcpcopy/

---

<div class="post-metadata">

**Author:** ![wangbin579](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bc79bd/32.png) [@wangbin579](https://www.ruby-forum.com/u/wangbin579)\
**Post date:** [November 3, 2011, 4:03am UTC](https://www.ruby-forum.com/t/tcpcopy-an-online-request-replication-tool-fit-for-nginx/213440/4 "2011-11-03T04:03:49Z")

</div>

An example:  
Suppose 13 and 14 are online machines, 148 is a target machine which  
is similar to  
the online machines, and 12321 is used both as local port and remote  
port. We  
use tcpcopy to test if 148 can endure two times of current online  
stress.

```
Using tcpcopy to perform the above test task.
the target machine(148)
   # modprobe ip_queue (if not run up)
   # iptables -I OUTPUT -p tcp --sport 12321 -j QUEUE (if not set)
   # ./interception
online machine(13):
   # ./tcpcopy xx.xx.xx.13 12321 xx.xx.xx.148 12321
online machine(14):
   # ./tcpcopy xx.xx.xx.14 12321 xx.xx.xx.148 12321

Cpu load and memory usage are as follows:
    13 cpu:
       11124 adrun 15 0 193m 146m 744 S 18.6 7.3 495:31.56

```

asyn\_server  
11281 root 15 0 65144 40m 1076 S 12.3 2.0 0:47.89 tcpcopy  
14 cpu:  
16855 adrun 15 0 98.7m 55m 744 S 21.6 2.7 487:49.51  
asyn\_server  
16429 root 15 0 41156 17m 1076 S 14.0 0.9 0:33.63 tcpcopy  
148 cpu :  
25609 root 15 0 76892 59m 764 S 49.6 2.9 63:03.14  
asyn\_server  
20184 root 15 0 5624 4232 292 S 17.0 0.2 0:52.82  
interception

```
Access log analysis:
    13 online machine: grep 'Tue 11:08' access_0913_11.log |wc -l

```

:89316, 1489 reqs/sec  
14 online machine: grep ‘Tue 11:08’ access\_0913\_11.log |wc -l  
:89309, 1488 reqs/sec  
148 test machine: grep ‘Tue 11:08’ access\_0913\_11.log |wc -l  
:178175, 2969 reqs/sec  
request loss rate:  
(89316+89309-178175)/(89316+89309)=0.25%

```
From the above, we can see that the target machine can endure two

```

times of current  
online stress.

```
What about the cpu load ?
tcpcopy on online machine 13 occupies 12.3% of cpu load, tcpcopy on

```

online 14  
occupies 14% and interception on target machine 148 occupies 17%. We  
can see  
that the cpu load is very low here, and so is the memory usage.

Posted at Nginx Forum:

> **[Re: Tcpcopy,an online request replication tool fit for nginx](https://forum.nginx.org/read.php?2,217680,217734#msg-217734)**
>
> Tcpcopy is an online request replication tool . It may be useful for migrating to nginx from apache https://github.com/wangbin579/tcpcopy or http://code.google.com/p/tcpcopy/

---

<div class="post-metadata">

**Author:** ![wangbin579](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bc79bd/32.png) [@wangbin579](https://www.ruby-forum.com/u/wangbin579)\
**Post date:** [November 3, 2011, 4:08am UTC](https://www.ruby-forum.com/t/tcpcopy-an-online-request-replication-tool-fit-for-nginx/213440/5 "2011-11-03T04:08:08Z")

</div>

a stress test for nginx written in chinese.

> **[利用tcpcopy，对nginx进行压力测试，效果见正文（注意用的是tcpcopy 0.5以下的版本）\_nginx tcp...](https://blog.csdn.net/wangbin579/article/details/6929495)**
>
> 从上午10：41分开始试验，一直到18：17，7个半小时左右。从4台nginx服务器拷贝流量到测试服务器，由于lvs有两个虚拟ip，在在线服务器执行命令如下：\[root@bgp176-141 work\]# ./tcpcopy xxx.xxx.xxx.140 80 xxx.xxx.xxx.148 18080root@bgp176-142 work\]# ./tcpcopy xxx.xx\_nginx tcp 复制

Posted at Nginx Forum:

> **[Re: Tcpcopy,an online request replication tool fit for nginx](https://forum.nginx.org/read.php?2,217680,217735#msg-217735)**
>
> Tcpcopy is an online request replication tool . It may be useful for migrating to nginx from apache https://github.com/wangbin579/tcpcopy or http://code.google.com/p/tcpcopy/

---

<div class="post-metadata">

**Author:** ![wangbin579](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bc79bd/32.png) [@wangbin579](https://www.ruby-forum.com/u/wangbin579)\
**Post date:** [November 8, 2011, 3:43am UTC](https://www.ruby-forum.com/t/tcpcopy-an-online-request-replication-tool-fit-for-nginx/213440/6 "2011-11-08T03:43:10Z")

</div>

Name:  
tcpcopy  
It is a request replication tool and is mainly for testing tasks  
using netlink and raw sockets

Description:  
It can help you find bugs in your online project without actually  
being online.  
And it can also be used to test the stress that a system could  
endure.

```
For example, if your system already has "memcached" subsystem and

```

you want to  
use “membase” to replace it, tcpcopy can assist you to test  
“membase”. While your  
old memcached system is still running online, tcpcopy could copy the  
flow of packets  
from memcached to membase. From the point view of membase, the flow  
is accessing  
membase(just like membase online), and it will not affect memcached  
at all except  
network bandwidth and a little cpu load.

Functionalities：  
1) Distributed Stress Test  
You can use online data to test the stress that your target  
machine can endure. It is better  
than apache ab tool and you can find bugs that only occur during  
high-stress situations.  
2) Hot Backup  
It is very suitable for backup tasks if connections are  
short-lived and the request loss rate  
is very low(1/100000).  
3) Normal Online Test  
You can find whether the new system is stable and find bugs that  
only occur in actual  
online environments.  
4) Comparison Test  
For example, you can use tcpcopy to compare the performances of  
apache and nginx.

Characteristics：  
1)real time  
2)realistic  
3)efficient  
4)easy to use  
5)distributed  
6)significant

Posted at Nginx Forum:

> **[Re: Tcpcopy,an online request replication tool fit for nginx](https://forum.nginx.org/read.php?2,217680,217954#msg-217954)**
>
> Tcpcopy is an online request replication tool . It may be useful for migrating to nginx from apache https://github.com/wangbin579/tcpcopy or http://code.google.com/p/tcpcopy/

---

<div class="post-metadata">

**Author:** ![wangbin579](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/bc79bd/32.png) [@wangbin579](https://www.ruby-forum.com/u/wangbin579)\
**Post date:** [November 10, 2011, 8:13am UTC](https://www.ruby-forum.com/t/tcpcopy-an-online-request-replication-tool-fit-for-nginx/213440/7 "2011-11-10T08:13:58Z")

</div>

tcpcopy-0.2.1.tar.gz is now available.  
Try it and I believe you will like this tool

Posted at Nginx Forum:

> **[Re: Tcpcopy,an online request replication tool fit for nginx](https://forum.nginx.org/read.php?2,217680,218138#msg-218138)**
>
> Tcpcopy is an online request replication tool . It may be useful for migrating to nginx from apache https://github.com/wangbin579/tcpcopy or http://code.google.com/p/tcpcopy/
