Skip to content

Trouble limiting tread pool size #32

Closed
pkaeding opened this Issue Nov 8, 2012 · 7 comments

3 participants

@pkaeding
pkaeding commented Nov 8, 2012

I seem to be having trouble limiting the thread pool size for the Async workers. Perhaps I am just missing something basic?

I declared my Http object like so:

val h = Http.threads(16)

However, when I run my app, the thread count climbs up towards 300, which makes me think it is still using the default of 256.

In order to isolate the issue, I have created a dummy web service, and a simple client. Feel free to grab this dummy code from https://bitbucket.org/pkaeding/dispatch-example to try running it.

Any ideas?

@n8han
n8han commented Nov 8, 2012

Are you sure it's not jetty threads? That thread limit in dispatch is just for evaluating the results of requests; the client can still make a lot more than 16 at once without dedicated threads.

@pkaeding
pkaeding commented Nov 8, 2012

Hmm, okay, maybe that's what's going on, then. When I examine the client as it runs in VisualVM, I see only 16 "New I/O Worker" threads, and many threads named just "Thread-N". From the thread dump, these threads like this:

"Thread-250" daemon prio=5 tid=0x00007fb3ca32d800 nid=0x15903 waiting on condition [0x00000001a0652000]
   java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for  <0x00000001638e83b0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1043)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1103)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

   Locked ownable synchronizers:
- None

Does that look like what you meant? Does Dispatch use Jetty under the hood? I'm seeing this when I run the client, which doesn't start up the Jetty server that I use for the dummy web service.

Thanks!

@softprops
@n8han
n8han commented Nov 8, 2012
@pkaeding

Ah no Dispatch doesn't use Jetty at all. I just saw jetty in your code
and assumed it was in the same VM.

Okay, so is this normal? Am I doing something wrong?

Thanks!

@n8han
n8han commented Nov 11, 2012
@n8han
n8han commented Sep 11, 2013

Hi, I'm closing out these old thread pool issues, feel free to bring it up on the list: https://groups.google.com/forum/#!forum/dispatch-scala

@n8han n8han closed this Sep 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.