question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Thread pool for Netty Threads [Question]

See original GitHub issue

I’m setting up a gRPC server based on Netty (netty-4.1.38). According to all docs/papers I’ve found, Netty has 3 types of threads: Boss, Worker, and Application Executor. I’ve set up a server with thread pools for all of them (thread number = 1 just for test).

NettyServerBuilder.forPort(port)
            .executor(Executors.newFixedThreadPool(1) {
                Thread(it)
                    .apply {
                        name = "Executor thread $id"
                    }
            })
            .workerEventLoopGroup(
                NioEventLoopGroup(1, ThreadFactory {
                    Thread(it)
                        .apply {
                            name = "Worker thread $id"
                        }
                })
            )
            .bossEventLoopGroup(NioEventLoopGroup(1, ThreadFactory {
                Thread(it)
                    .apply {
                        name = "Boss thread $id"
                    }
            }))

But when I run the server and connect with the client, I see some extra “Netty Threads” apart from those 3 expected (Boss, Worker, and Executor are present there too).

image

The call stack for such thread looks like this: image

So it seems to be doing exactly the same thing as Worker threads do.

Also, more of these threads are spawning as the load increases. And my question is, what are those and why I can’t control them via any thread pool? I’ve searched through both Netty and gRPC repos and didn’t find any Thread factory that spawns threads with “Netty Thread” name.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Dimeziscommented, Aug 3, 2019

Alright, mystery solved 😃 Thank you guys for help! So in my case it was a Lightstreamer library, totally forgot about it, and actually had no idea it uses Netty.

1reaction
njhillcommented, Aug 2, 2019

@ninja- ah yes you’re right of course! But my client question still applies 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How Netty uses thread pools? - java - Stack Overflow
The worker thread pool has to be able to deliver at least Number of Workers threads (currently default 2*number of cores).
Read more >
Thread model - Netty.docs
We solve the problem where Netty creates as many threads as the number of open server ports. We can share a pool of...
Read more >
Netty data model, threading, and gotchas | by Ammar Khaku
Netty data model, threading, and gotchas ... I/O (NIO) which allows you to create a thread pool and handle a large number of...
Read more >
Chapter 7. EventLoop and threading model - Netty in Action
In this chapter we'll examine Netty's threading model in detail. ... A Thread is selected from the pool's free list and assigned to...
Read more >
Concurrency in Spring WebFlux - Baeldung
Note that, apart from a normal thread for the server, Netty spawns a bunch of worker threads for request processing. These are typically ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found