Lot of UDP requests lost in UDP server with Netty Lot of UDP requests lost in UDP server with Netty multithreading multithreading

Lot of UDP requests lost in UDP server with Netty


You have not properly configured the ConnectionlessBootstrap instance.

  1. You have to configure followings with optimum values.

    SO_SNDBUF size, SO_RCVBUF size and a ReceiveBufferSizePredictorFactory

    lBootstrap.setOption("sendBufferSize", 1048576);lBootstrap.setOption("receiveBufferSize", 1048576);lBootstrap.setOption("receiveBufferSizePredictorFactory",  new AdaptiveReceiveBufferSizePredictorFactory(MIN_SIZE, INITIAL_SIZE, MAX_SIZE));

    check DefaultNioDatagramChannelConfig class for more details.

  2. The pipeline is doing everything using the Netty work thread. Ifworker thread is overloaded, it will delay the selector event loopexecution and there will be a bottleneck in reading/writing thechannel. You have to add a execution handler as following in thepipeline. It will free the worker thread to do its own work.

    ChannelPipeline lChannelPipeline = Channels.pipeline();lChannelPipeline.addFirst("execution-handler", new ExecutionHandler(  new OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576));//add rest of the handlers here