Git Product home page Git Product logo

websocket_agent's Introduction

是一个将websocket转成tcp的代理,用了此代理之后,可以直接用原来的tcp服务器,然后客户端用websocket进行通信。 this can receive websocket from one client then connect to a server by tcp , then transfer msg between them.

用法 usage: websocket_transfer_tcp 8888 0.0.0.0:8889 (客户端用websocket连接8889端口,然后转移到8888端口的tcp服务器)

代理性能测试:

测试机器: 腾讯云 4核4G内存,go版本1.5.1

初次测试: 1W连接,连续不断发消息,会到6W+ /s 读写次数,si45%左右,(每秒10个左右的连接会等待超过2秒,其他都很快)

	  之后改成每个连接都是1秒发送一次消息则可以将连接增加到2W8左右无压力,之后出现连接不上的情况。

机器调优: 发现是可用端口已经到达极限(linux默认可用端口为32768-61000)

	  修改可用端口:   /etc/sysctl.conf
	  
	  net.ipv4.ip_local_port_range = 1024 65535
	  
	  sysctl -p

最终测试: 最后可到6W左右连接,每个连接1S发送一条数据, 读写为6W/s si有到70% 左右 (每秒30个所有的连接会等到超过2S)

因没有做连接收缩,所以只能到6W连接,此时压力也比较正常。

websocket_agent's People

Contributors

zxb19890727 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.