Azure / Azure/DotNetty

Parameter optimization adjusted through pressure testing

Open
#634 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.3k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Hello, Dotnetty community. As the open source project uses Dotnetty, this project is very important to me. Based on Dotnetty, we have extended RTMP, rtsp,httflv, The open-source IoT platform will also be based on Dotnetty in the future, so this project is great. Stress testing allows me to adjust and optimize parameters without blocking, memory leaks, or 16mb Chunks. Here is my configuration, hoping to help everyone:
1. Configure environment variables
```
1 Environment. SetEnvironmentVariable("io.netty.allocator.maxOrder", "5");
2 Environment. SetEnvironmentVariable("io.netty.allocator.numDirectArenas", "0");
3 Environment.SetEnvironmentVariable("io.netty.allocator.type", "unpooled");
4 Environment. SetEnvironmentVariable("io.netty.allocator.numHeapArenas", "0");
```
2. Group configuration Libuv for server bootstrap
```
var dispatcher = new DispatcherEventLoopGroup();
var bossGroup = dispatcher;
var workerGroup = new WorkerEventLoopGroup(dispatcher, AppConfig.ServerOptions.EventLoopCount);
bootstrap
.Option(ChannelOption.SoBacklog, AppConfig.ServerOptions.SoBacklog)
.ChildOption(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default)
.ChildOption(ChannelOption.SoReuseaddr,true)
.Group(bossGroup, workerGroup)
```
3. Group configuration MultithreadEventLoopGroup for client bootstrap
```
var group = new MultithreadEventLoopGroup(AppConfig.ServerOptions.EventLoopCount);
bootstrap
.Channel()
.Option(ChannelOption.TcpNodelay, true)
.Option(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default)
.Group(group);
```
4. Message destruction
```
public override void ChannelRead(IChannelHandlerContext context, object message)
{
var buffer = (IByteBuffer)message;
try
{
var data = new byte[buffer.ReadableBytes];
buffer.ReadBytes(data);
var transportMessage = _transportMessageDecoder.Decode(data);
context.FireChannelRead(transportMessage);
}
finally
{
ReferenceCountUtil.Release(buffer);
}
}
```
5. Use Task.run or Channel Pipeline to execute business through EventExecutor

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.