Giter Site home page Giter Site logo

tcp server cpu飙升 about jsonrpc4go HOT 4 CLOSED

sunquakes avatar sunquakes commented on June 8, 2024
tcp server cpu飙升

from jsonrpc4go.

Comments (4)

lizuoqiang avatar lizuoqiang commented on June 8, 2024

连续请求几次cpu就跑到100%了

from jsonrpc4go.

lizuoqiang avatar lizuoqiang commented on June 8, 2024

文件:server/tcp.go
方法:handleFunc
去掉外层for循环

from jsonrpc4go.

sunquakes avatar sunquakes commented on June 8, 2024

感觉是缓存区太小,频繁对比eof导致cpu上升,我这边测试下

from jsonrpc4go.

sunquakes avatar sunquakes commented on June 8, 2024

1、issues #2 可以通过之前的配置PackageMaxLength实现,代码如下。默认的一次取数据slice已经足够长了,还出现数据不全的情况可能是因为你的tcp缓存区较小,程序已兼容

  • server
s.SetOptions(server.TcpOptions{"\r\n",  2 * 1024 * 1024})
  • client
c.SetOptions(client.TcpOptions{"\r\n", 2 * 1024 * 1024})

2、cpu飙升原因:连接断开后,主进程不退出,会死循环。你给出的解决方案解决不了长连接的情况,程序已加判断,在连接断开后,直接退出循环

from jsonrpc4go.

Related Issues (3)

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.