Azure / DotNetty

DotNetty project – a port of netty, event-driven asynchronous network application framework
Other
4.09k stars 977 forks source link

Can't hold 100+ connections #333

Closed pvictorlv closed 6 years ago

pvictorlv commented 6 years ago

I've tested dotnetty in my server with 500+ connections and when reach in 100~150 it just don't accept more connections. My server is an game server.

Here is my code: https://pastebin.com/Tr7gajmN

https://pastebin.com/Fn3WnQ1N

StormHub commented 6 years ago

from https://pastebin.com/Fn3WnQ1N ChildServerWorkers = new MultithreadEventLoopGroup(1);

You are using ONE thread to handle all client connection tasks! If you are serving large amount of client connections, you'd better use multiple threads(event loops).

// This will spawn threads equal to the number of CPU cores ChildServerWorkers = new MultithreadEventLoopGroup();

nayato commented 6 years ago

@darkinghb considering there's a good amount of unknown code in here, any chance something there might be blocking? That might explain stalls or unnaturally low throughput.

caozhiyuan commented 6 years ago

it better run a task handle request in channleread.

pvictorlv commented 6 years ago

@StormHub I've changed to 8, but same thing, when i don't limit it, it use 100% cpu, any idea?

StormHub commented 6 years ago

@darkinghb It is recommended to be the same as number of CPUs (default). BTW: Whats the platform you are running on? There are a few things you can try set the backlog to 8192 might help a bit. And whats the actually SoRcvbuf value (GameSocketManagerStatics.BufferSize) The CPU busy probably is caused by large number of task wait spins (but you need to profile to know for sure)

pvictorlv commented 6 years ago

I'm running on windows server 2016 (.net 4.7, cpu xeon 10x2.6ghz), i can post here profile tests later (at night), i'll set the backlog and increase the limit of MultithreadEventLoopGroup and test.

pvictorlv commented 6 years ago

the buffersize is 8192

nayato commented 6 years ago

@darkinghb if CPU is a bottleneck - profile. Check PerfView. It will give you enough of an insight into the situation. I'm quite positive DotNetty can handle 100K connections on a single VM with no problem (given traffic is small over most of them).

nayato commented 6 years ago

Closing for the lack of updates. Feel free to reopen if there's further concern with this.