0

I am trying to optimize the undertow server and I wanted to try setting the I/O threads (WORKER_IO_THREADS and WORKER_TASK_CORE_THREADS) for my HttpListener. Could you please help me with the required steps?

Undertow server = Undertow.builder().addHttpListener(80, "")
                .setHandler(new HttpHandler() {
                public void handleRequest(final HttpServerExchange exchange)
                        throws Exception {
                    String string_exchange = exchange.getQueryString();
                    str = <some work on string_exchange>
                    exchange.getResponseSender().send(str);
                }
            }).build();
server.start();

I did read that the XNIO worker associated with the listener needs to be configured. However I am not clear on how to go about this.

pm2014
  • 11
  • 1
  • 4

1 Answers1

0

I'm afraid that you need to take a long road of bootstrapping Undertow manually as described in the documentation. The reason for that is that all Handlers share the NIO pools from one XnioWorker.

XnioWorker worker = xnio.createWorker(OptionMap.builder()
    .set(Options.WORKER_IO_THREADS, ioThreads)
    .set(Options.WORKER_TASK_CORE_THREADS, workerThreads)
    .set(Options.WORKER_TASK_MAX_THREADS, workerThreads)
    .set(Options.TCP_NODELAY, true)
    .getMap());
Amr Eladawy
  • 4,193
  • 7
  • 34
  • 52
atok
  • 5,880
  • 3
  • 33
  • 62