Comments (4)
@lonerwolf
现在是用 round-robin 轮询分配的,怎么会导致连接都分配到一个 poller 里?
from gnet.
@lonerwolf
现在是用 round-robin 轮询分配的,怎么会导致连接都分配到一个 poller 里?
因为轮询,所有有问题,比如2个EPOLL,进来2个连接,两个都是一个,然后2号EPOLL里的这个连接断开了,他重新连接就到1号上去了,不断累积就不平衡了
from gnet.
客户端连接是长连接和短连接混合的时候,Round-Robin 负载均衡的确会出现你说的这种问题,这是算法决定的,所以我建议你复用连接或者用 gnet
的 SO_REUSEPORT 模式,让内核来做负载均衡。
因为 Round-Robin 最好实现也最简洁而且性能表现也比较好,所以当初就选择它作为内置负载算法。关于新增其他负载均衡算法,其他算法像最少连接、一致性 Hash 等,可能需要引入新的参数和额外的逻辑(可能会带来性能损耗),我还在调研,慢慢会加入新的负载算法的。
from gnet.
我建议以fd来分配loop,取得连接fd分配之后,将fd分配到 idx为nfd%svr.subLoopGroup.len()的loop里。
那么我们来复现疑问场景。
loop总数为2,fd为1分配到loop1,fd为2分配到loop0。fd2断开,重新再连,获得的fd还是2,2%2=0,这时候分配到loop0,实现均衡:smile:
from gnet.
Related Issues (20)
- [Question]: gnet engine is stopping with error: kevent add|clear:function not implemented HOT 5
- [Question]: 您好大佬,这个库的epoll的底层实现是用纯go实现的吗?没有用到cgo是吧? HOT 1
- [Feature]: how to disable logging? replace uber zap with zerolog too pls HOT 3
- [Question]: The TechEmpower Benchmark is misleading, but can we make it even faster? HOT 1
- [Feature]: add synchronization for Conn to make it concurrency-safe HOT 1
- [Question]: What is the maximum number of cores tested by anyone? I just tested 192 cores and it's better than evio etc but... HOT 7
- [Question]: Will the OnTraffic function be called concurrently? HOT 1
- [Question]: Validate the approach of implementing persistent TCP connections. HOT 1
- [Bug]: Calling Dial() in version 2.4 of Windows 10 will block HOT 4
- [Question]: I would like to verify whether this problem in the screenshot will cause the memory of the service to slowly increase. HOT 1
- [Feature]: support edge-triggered I/O
- [Question]: Is the netpoll v1 version defaulting to horizontal triggering, and the V2 version defaulting to edge triggering? HOT 15
- [Bug]: fatal error: concurrent map read and map write HOT 1
- Inconsistent behaviors with SO_REUSEPORT on Linux and *BSD HOT 7
- Don't use SO_REUSEPORT on Unix domain sockets HOT 1
- Don't disable SO_REUSEPORT on DragonFlyBSD HOT 1
- [Question]: gnet client works not as expected even tho i did it according to the api ref HOT 1
- [Bug]: GNET client not working as expected HOT 4
- [Bug]: example gnet for echo tcp uses too much memory HOT 7
- [Bug]: Read returns io.ErrShortBuffer on closed connection HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gnet.