Skip to content

Parameter optimization adjusted through pressure testing #634

@fanliang11

Description

@fanliang11

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");
  1. 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)
  1. 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);
  1. 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);
}
}
  1. Use Task.run or Channel Pipeline to execute business through EventExecutor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions