-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
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:
- 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");
- 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)
- Group configuration MultithreadEventLoopGroup for client bootstrap
var group = new MultithreadEventLoopGroup(AppConfig.ServerOptions.EventLoopCount);
bootstrap
.Channel<TcpSocketChannel>()
.Option(ChannelOption.TcpNodelay, true)
.Option(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default)
.Group(group);
- 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);
}
}
- Use Task.run or Channel Pipeline to execute business through EventExecutor
Metadata
Metadata
Assignees
Labels
No labels