java - Tomcat connector architecture, thread pools and async servlets -


i understand tomcat's thread model bio , nio connectors. referencing official tomcat 7 documentaion connectors can found here. based on it, have in doubt:

  • acceptorthread(s) : single or @ 2 threads (as mentioned in doc) responsible accepting in-coming connections. can configured using acceptorthreadcount, , it's suggested more 2 can used multi-cpu machine -
    • why ?
    • does imply number of simultaneous open connections scales number of cpus versus number of open file descriptors allowed on server system ?
  • maxconnections(s) :
    • what relation between setting , acceptcount , number of open file descriptors on system.
    • why default value higher nio connector ( 10000 ) bio ( = maxthreads ) ?
  • acceptcount : queue requests when request processing threads busy.
    • when requests put queue, file descriptor assigned ? or when request being actively processed, consume file descriptor ?
  • request processing threads : number of threads in pool configured maxthreads , minsparethreads attributes.
    • what relation between thread pool , acceptorthreads ? acceptor thread(s) spawn threads in pool ?
    • as understand, nio model more efficient request processing threads bio model. how achieve efficiency ?
    • as i've read in various sources, threads in nio model follow thread per request paradigm vs thread per connection paradigm of bio model. also, in nio connector model, actual request processing delegated different, application monitored thread while server's request processing thread returned thread pool- free accept more connections. so, imply benefit of nio model apparent if connections server of http keep-alive nature or if application using servlet 3.0's asynchronous processing feature ?
  • servlet 3.0 :
    • when using servlet 3.0, should size of application servlet thread pool ( relative connector thread pool size ) achieve optimum efficiency ?
    • when using bio model , together, there difference how requests processed ( given connector threads still using thread per connection model ) ?

please note: discussion respect tomcat 7.

  • acceptorthread(s) : single or @ 2 threads (as mentioned in doc) responsible accepting in-coming connections. can configured using acceptorthreadcount, , it's suggested more 2 can used multi-cpu machine -

    why ?

accepting connections low cost operation doesn't make sense dedicate more 1 thread task.

does imply number of simultaneous open connections  scales number of cpus versus number of open file descriptors  allowed on server system ? 

no doesn't because it's low cost operation in terms of cpu. file descriptors, each accepted connection going use file descriptor, maxim number of connections server can accept limited number of available file descriptors.

  • maxconnections(s) :

    what relation between setting , acceptcount , number of open file descriptors on system.

maxconnections cannot higher number of open file descriptors on system. keep in mind other processes use file descriptors well, may want conservative maxconnections in regards available file descriptors, let's maxconnections < file descriptors / 2.

why default value higher nio connector  ( 10000 ) bio ( = maxthreads ) ? 

this because in nio single handles io, , in bio server need create/use separate thread-per connection.

  • acceptcount : queue requests when request processing threads busy.

    when requests put queue, file descriptor assigned ?

yes, that's correct connection request accepted server not yet ready being serving requests, connection placed in queue. done prevent tcp/stack timing out connection requests may server down client point of view. in other words, server says 'i'm here , process request once have resources it'.

or when request being actively processed, consume file descriptor ?

nope.

hope helps.

regards,

slava imeshev


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -