Giter Site home page Giter Site logo

tcp_proxy's Introduction

This is a test to validate a proxy using splice for copying between client<->proxy<->remote sockets as opposed to transferring data without splice using read and write syscalls.

The read and write socket approach would incur an additional 2 copies in the kernel to transfer data to and from the user space.

The splice syscall avoids the double copy by using an intermediate pipe buffer to transfer data across 2 socket buffers in kernel.

This approach in general should result in faster throughput but the variance in performance should be dependent on NIC cards. If the NIC cards support zero-copy or DMA in/out from the pipe buffer to the socket buffer, then the transfer should be fast.

Testing the approach with a simple tcp ping server, tcp ping client through a proxy doesn't seem to see any/big gains. The CPU performance difference between 2 approaches is minimal.

In fact, I expect the CPU usage to be higher using the splice approach considering the copy_to_user/copy_from_user in the read/write approach is a preemption point and could result in context switches resulting in proxy's bandwidth being lower when running without the splice or the traditional read/write socket approach.

In order to validate it, you can run it on a real hardware since I had run them on a VBOX VM on the same node without incurring the NIC transfers.

To run;

make

Start tcp_ping_server,

./tcp_ping_server -s

On another shell, start the proxy:

./proxy -s <ip_address> -z -r

(type -h for help options)

The "-z" option enables splice approach for the proxy to transfer data between client and remote server. Without -z, it would fall back to traditional approach.

Now on another shell, start the tcp client through the proxy,

./tcp_ping_client -p 9998 -s -n 10000

The above would send/recv 10000, 1024 byte packets between client and server through the proxy and would display the bandwidth after the test.

Just use -n 0 to run forever and check cpu usage.

In my testing, I didn't see any perceivable difference though I am sure with real NIC, splice approach would be favorable and would only result in better throughput overall for the proxy.

Nice to have ...

Regards,

-Karthick

tcp_proxy's People

Contributors

karthick18 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.