Coder Social home page Coder Social logo

gotunnel's Introduction

原理

tunnel stack

SOURCE DESTINATION
TcpConn TCPConn
Link Link
Coor Coor
Tunnel Tunnel

组件

  • back server, back client: 负责建立tunnel
  • front server: 负责接受玩家连接
  • coor, link set: 负责管理link
  • link: 抽象的概念,实际连接在tunnel上的映射

build

如果没有搭建过go 的workspace,参考install.sh里面的脚本

go install gotunnel

run

###launch gate(defaut port 8001, 8002):

./gotunnel -gate

###launch node(defaut service port 1234):

./gotunnel -back_addr=127.0.0.1:8002 settings.conf

###launch service:

nc -lk 1234

###launch client:

nc 127.0.0.1 8001

benchmark

测试环境

  • OS:Ubuntu quantal (12.10)
  • CPU: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz
  • golang: go1.2.1 linux/amd64

gotunnel启动参数

  • gate:./gotunnel -gate
  • node:./gotunnel -back_addr 127.0.0.1:8002 settings.conf

nginx 作为后端

  • nginx/1.2.1
  • 测试工具使用ab (version 2.3), 10000次请求
  • 下表对比(Requests per second)
并发数 no tunnel go tunnel(CPU=1) go tunnel(CPU=2)
1 7473 1902 1826
10 21734 7508 7627
100 20408 8681 10255
500 18548 8000 5417
  • 并发上去之后,go的效率提升不明显,在100并发数附近结果最好,有点奇怪。
  • 也使用redis-benchmark进行了测试,结果略好一点。

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.