Hi Emmanuel,

By increasing num of threads of handling, i believe i have done so,

*|UDPListener| --> |MainAdapterHandler| --> |KafkaProducer|*

This is basic of my application, so to summarize

1. - UDPListener: this class holds NioDatagram objects etc;
2. - MainAdapterHandler: this class holds all of my handling logic,
   extends IoHandlerAdapter Inside this class, i called KafkaProducer
   to submit message

 Things to notes are:

1. I set a threadpool executor as parameter of NioDatagramAcceptor, the
   executor has max value of available processors (acceptor=
   newNioDatagramAcceptor(IOExecutor.get());)
2. I set a threadpool in defaultIoChainBuilder
   (chain.addLast("threadPool",
   newExecutorFilter(filterChainBuilderExecutorMaxPoolSize));)
3. Also, i make MainAdapterHandler class threaded by creating a class
   extends Thread (ThreadedHandlerAdapter), so if i set another
   executor, this line will be executed
   (executor.get().execute(newThreadedHandlerAdapter(this, session,
   message));)

Or am i missing somethings here?

Thank you


On 17/01/2024 17:00, Emmanuel Lécharny wrote:
Hi,

hard to tell.

Have you profiled your application? Are you CPU bound? If not, you should probably increase the default number of threads capable of handling the incoming messages (it defaults to Nb cores + 1 )

On 16/01/2024 09:04, Bobby R. Harsono wrote:
Hi all,

Im using Mina 2.2.3 to build a UDP Server,

Currently, i implemented one IoHandlerAdapterclass, lets call this MainHandlerAdapter, inside i have plenty of variables of custom instance; Several of them are @Autowired on the parent class and when creating UDP Server i set them through constructor.

In the end of processing, i use KafkaProducer class to send event to kafka topic. All is fine and well, until i found leaked threads, i fixed this by

1. supplying custom threadpool executor in acceptor=
    newNioDatagramAcceptor(IOExecutor.get());
2. removing @Async on my send() method in KafkaProducer - this way,
    will not spawn any more threads
3. made MainHandlerAdapter threaded,
4. supply executor in filterchainbuilder -> DefaultIoFilterChainBuilder
    chain = acceptor.getFilterChain();
    chain.addLast("threadPool", new
    ExecutorFilter(Executors.newCachedThreadPool()));

The thread leaked is no more but there is another problem,

My UDP Listener received around 500k TPS, an instance deployed in K8 can handle around 30-50k TPS but when measuring with core utilizing, 1 core only handled around 1-4k TPS, this is very low compared to another component (not using Mina) that achieved minn 8k TPS

Are there any suggestions how to improve my UDP Server performance ??

Another problem is when i increased deployment pod, no significant tps improved



--
-----------
Bobby R. Harsono
Software Developer
Tricada Intronik - Bandung

Reply via email to