I'm trying to build a UDP server based on Netty to continuously publish events (about 500 events per second) to different clients based on client subscription (a few UDP request/response messages are exchanged before a subscription setup).
The design is to have a few producer/consumer threads created by Java Executors. Once a messages is generated, consumer threads will write it to the UDP channel.
The observation is there's only one EventLoop thread working for that UDP channel in server end, and it is quite busy with writing messages to socket, so the response to the 2nd and later client's subscription request is quite slow.
So wondering if any way to enable multiple worker threads for NIO UDP server end, so that one or a few threads busy with writing publishing events to socket, we still have other threads to process new client subscription requests without delay. Any suggestions are much appreciated.
btw, server-side Netty handlers are quite simple: a logging handler, a decoder hander, a encoder handler, and a subscription handler.
codeBootstrap udpBoot = new Bootstrap(); udpBoot.group(new NioEventLoopGroup(10).channel(NioDatagramChannel.class).option(ChannelOption.SO_BROADCAST, true).option(ChannelOption.SO_REUSEADDR, true).handler(new ChannelInitializer<Datagram>(){ @Override protected void initChannel(DatagramChannel ch) throws Exception {ch.pipeline().addLast(loggingHandler).addLast(new MyDatagramToPojoDecoder(adapter)).addLast(new MyPojoToDatagramEncoder(adapter)).addLast(new MySessionHandler(service)).addLast(new MySubscriptionHandler(service));}});code- Wei Song