Search code examples
httpclojureluminus

Clojure: What is the default server for the luminus framework?


As of right now (2018) what is the http/tcp server used when you set up a luminus template project with its default setting?

I'm reading that luminus uses immutant, however, immutant is a collection of other stuff. and I've also read that the underlying server used in immutant is undertow.

Am I correct in assuming that the default server is undertow? If so, how does the default set up perform with respect to non-blocking IO? Does this server afford a non-blocking event loop architecture like nginx/nodejs?


Solution

  • You are correct that Immutant uses Undertow as its web server.

    Undertow uses non-blocking IO threads (typically one per CPU core) and also manages a pool of worker threads. To quote their documentation:

    The XNIO worker manages both the IO threads, and a thread pool that can be used for blocking tasks. In general non-blocking handlers will run from withing an IO thread, while blocking tasks such as Servlet invocations will be dispatched to the worker thread pool.

    IO threads run in a loop. This loop does three things:

    • Run any tasks that have been scheduled for execution by the IO thread
    • Run any scheduled tasks that that have hit their timeout
    • Call Selector.select(), and then invoke any callbacks for selected keys

    The obvious difference between this architecture and a node architecture is the separation of the pool of worker threads, which are allowed to block.

    I'm afraid I can't speak to comparing actual performance, which would be use-case specific.