Coder Social home page Coder Social logo

例子循环10000次出错 about rpcx HOT 5 CLOSED

smallnest avatar smallnest commented on May 19, 2024
例子循环10000次出错

from rpcx.

Comments (5)

smallnest avatar smallnest commented on May 19, 2024

the Operating System runs out of memory for TCP buffers.
每个client都会建立一个到服务器的连接。你改成10000会导致windows 内存占光。建议使用处理client连接池

from rpcx.

seewindcn avatar seewindcn commented on May 19, 2024

callServer函数里面,不是有client.Close()吗?这个循环是顺序来的,建立一个client,执行,close这个client;这样也会耗光内存?除非这个close不是马上执行的?

from rpcx.

smallnest avatar smallnest commented on May 19, 2024

我明天测一下,看你提供的错误似乎资源不足。

from rpcx.

smallnest avatar smallnest commented on May 19, 2024

你说的逻辑没错,callServer是在一个goroutine中顺序执行的。但是socket关闭后端口并不会释放,相应的端口会处于TIME_WAIT的状态,只有等待两个MSL才会释放。 这不仅仅是在Windows上的问题,Linux也有这个问题。 所以你可以把HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters/TcpTimedWaitDelay改小,促使port尽快释放。

更有效的是使用client pool.只保留几个长连接。我会加上连接池的例子。

  TCP    127.0.0.1:50404        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50405        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50406        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50407        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50408        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50409        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50410        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50411        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50412        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50413        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50414        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50415        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50416        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50417        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50418        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50419        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50420        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50421        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50422        activate:8972          TIME_WAIT
  TCP    127.0.0.1:50423        activate:8972          TIME_WAIT

from rpcx.

seewindcn avatar seewindcn commented on May 19, 2024

明白,是TIME_WAIT的状态,谢谢解释!

from rpcx.

Related Issues (20)

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.