Giter Club home page Giter Club logo

Comments (19)

xtaci avatar xtaci commented on July 18, 2024

应该是GC不及时的问题,是不是一个低端CPU?
可以启动时增加环境变量,例如GOGC=20 ./client_xxxxx,提高回收频率。

from kcp-go.

xtaci avatar xtaci commented on July 18, 2024

两个可以设置的环境变量。

The GOGC variable sets the initial garbage collection target percentage. A collection is triggered when the ratio of freshly allocated data to live data remaining after the previous collection reaches this percentage. The default is GOGC=100. Setting GOGC=off disables the garbage collector entirely. runtime/debug.SetGCPercent allows changing this percentage at run time.

The GOMEMLIMIT variable sets a soft memory limit for the runtime. This memory limit includes the Go heap and all other memory managed by the runtime, and excludes external memory sources such as mappings of the binary itself, memory managed in other languages, and memory held by the operating system on behalf of the Go program. GOMEMLIMIT is a numeric value in bytes with an optional unit suffix. The supported suffixes include B, KiB, MiB, GiB, and TiB. These suffixes represent quantities of bytes as defined by the IEC 80000-13 standard. That is, they are based on powers of two: KiB means 2^10 bytes, MiB means 2^20 bytes, and so on. The default setting is math.MaxInt64, which effectively disables the memory limit. runtime/debug.SetMemoryLimit allows changing this limit at run time.

from kcp-go.

purpleroc avatar purpleroc commented on July 18, 2024

好像还是不太行。会跑飞,云上机器4c8g。
GOGC=50 GOMEMLIMIT=5368709120 nohup ./linux_server &
还是跑飞了...

from kcp-go.

xtaci avatar xtaci commented on July 18, 2024

不用nohup呢,nohup我不确定会不会继承环境变量。你可以用tmux

from kcp-go.

xtaci avatar xtaci commented on July 18, 2024

GOGC再小点,GOGC=10

from kcp-go.

xtaci avatar xtaci commented on July 18, 2024

我自用的1c2g都没事

from kcp-go.

purpleroc avatar purpleroc commented on July 18, 2024

直接 GOGC=10 GOMEMLIMIT=4368709120 ./linux_server也崩了。。。 估计是我请求太频繁、流量太多导致的?
nohup是可以继承的

from kcp-go.

xtaci avatar xtaci commented on July 18, 2024

cpu跑满了么

from kcp-go.

purpleroc avatar purpleroc commented on July 18, 2024

cpu 持续 200% +

from kcp-go.

xtaci avatar xtaci commented on July 18, 2024

那就是某种原因导致了cpu全部消耗了,并且没有多余的时间用于GC,要么是配置错误,要么就是持续超高流量,那确实就是需要这么多内存和CPU

from kcp-go.

purpleroc avatar purpleroc commented on July 18, 2024

配置错误是指?

from kcp-go.

xtaci avatar xtaci commented on July 18, 2024

例如interval, fec, fastack这类通信参数

from kcp-go.

purpleroc avatar purpleroc commented on July 18, 2024

好像都是没设置,和kcp相关的,就只设置了下面这些:

			conn, err := uln.AcceptKCP()
			if err != nil {
				log.Error().Msg(err.Error())
				continue
			}
			conn.SetStreamMode(true)
			conn.SetWriteDelay(false)
			conn.SetNoDelay(1, 10, 2, 1)
			conn.SetWindowSize(128, 128)
			conn.SetACKNoDelay(true)

from kcp-go.

xtaci avatar xtaci commented on July 18, 2024

conn.SetACKNoDelay(true) 这个不需要设置

from kcp-go.

purpleroc avatar purpleroc commented on July 18, 2024

下午刚对着你的 kcptun 加上的 哈哈

from kcp-go.

purpleroc avatar purpleroc commented on July 18, 2024

除了这个选项,直接改sess.go的话,有什么建议么?

from kcp-go.

xtaci avatar xtaci commented on July 18, 2024

没有,主要是找到cpu满载的原因

from kcp-go.

purpleroc avatar purpleroc commented on July 18, 2024

估计是交互量太大导致的。
我改了下面俩,然后,似乎现在稳定了。

			conn.SetNoDelay(0, 20, 0, 0)
			conn.SetWindowSize(256, 256)

from kcp-go.

purpleroc avatar purpleroc commented on July 18, 2024

大概知道了,可能是得在udp收数据的地方加一个判断,判断是会否kcp相关上数据,不然每个包都进去,量级太多的时候,就释放不过来了。
结单,感谢大佬

from kcp-go.

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.