On 08/09/2014 04:20, Xfeep wrote:
  In addition one Java thread will tie up one native OS thread.
A
On Monday, September 8, 2014 10:50:13 AM UTC+8, Yuexiang Zhang wrote:

    Not only Wildfly but also most of mainstream pure java webservers
    use thread pool to handle http requests. Nginx-Clojure can also be
    configurated to use thread pool with one or many JVM instances.

    Advanced Java webservers use Java NIO (I/O multipexing) to do the
    first phrase (Http request accepting and simple parsing)  then run
    user business flow with thread pool. The first phrase only need one
    or very few threads. But at the second phrase (using thread pool)
    largely existing Java Socket API based libraries such as JDBC
    drivers, Http Client are  blocking so if there are many connections
    they 'll eat up all threads and make the webserver hang because a OS
    can only support less threads than connections. By the way threads
    in JVM are not cheap and they use more memory than pure native OS
    threads and OS threads are pre-emptive and scheduled at constant
    time slice so if there are too many threads scheduling will cost too
    many of cpu cycles to do real works.

    For large scalar application one JVM instance is really not enough.
    Typical scenario is we use serveral Java webservers such as tomcat,
    jetty, glassfish etc, and
    put a reverse proxy such as Nginx, Haproxy, Apache in the front of
    them. And Nginx-Clojure make this work easier because it can
    automatic embed JVM instances into Nginx worker processes and we
    need not maintain too many webservers.

    Since JDK 5, JVM instances can share Class data to reduce memory
    usage and the startup time for java applications. And on our
      enviroment typically we use coroutine based sockets to work with
    Apache http client , Solr client ,etc. Coroutines are cooperative
    and cheaper than threads and be created as much as our memory can bear.

    Xfeep


Thanks. Very informative. 'Looks like Nginx-Clojure is a good option.

gvim

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to