Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Serialized access to servlet

Hey guys,

I'm having a situation where requests to a servlet seem to be run in serial instead of in parallel.
I have done quite a lot of debugging and the problem seems to be inside Jetty, so I thought I'd ask you under what conditions access to a servlet would become serialized.

(access to different services at the same time (parallel) works, but not same service in parallel)

Setup:
Jetty 7.14
Jersey 1.2

I'm having an RS-bean defined like this:

@Path("/scalacount")
class SimpleService {
  @GET
  @Produces(Array("text/html"))
  def count = {
    Logger("SimpleService").error("Before Sleep")
    Thread.sleep(10000)
    Logger("SimpleService").error("After Sleep")
    "someresult"
  }
}

The problem is that when I request http://mycomputer:myport/scalacount
from two tabs at the same time, I get an output that looks like this:

[ERROR] [2010-09-07 22:46:27,207] [qtp1568367177-85 - /scalacount] SimpleService: Before Sleep
[ERROR] [2010-09-07 22:46:37,208] [qtp1568367177-85 - /scalacount] SimpleService: After Sleep
[DEBUG] [2010-09-07 22:46:37,437] [qtp1568367177-85 - /scalacount] o.e.j.u.log: RESPONSE /scalacount  200
[DEBUG] [2010-09-07 22:46:37,510] [qtp1568367177-82 - /scalacount] o.e.j.u.log: REQUEST /scalacount on org.eclipse.jetty.server.nio.SelectChannelConnector$2@5805dc52
[DEBUG] [2010-09-07 22:46:37,510] [qtp1568367177-82 - /scalacount] o.e.j.u.log: servlet=se.scalablesolutions.akka.comet.AkkaServlet-868246527
[DEBUG] [2010-09-07 22:46:37,511] [qtp1568367177-82 - /scalacount] o.e.j.u.log: servlet holder=
[DEBUG] [2010-09-07 22:46:37,511] [qtp1568367177-82 - /scalacount] o.e.j.u.log: chain=
[ERROR] [2010-09-07 22:46:37,512] [qtp1568367177-82 - /scalacount] SimpleService: Before Sleep
[ERROR] [2010-09-07 22:46:47,512] [qtp1568367177-82 - /scalacount] SimpleService: After Sleep
[DEBUG] [2010-09-07 22:46:47,514] [qtp1568367177-82 - /scalacount] o.e.j.u.log: RESPONSE /scalacount  200


I.e. instead of being run in parallel they are run after eachother, which they, to my knowledge should now.

I'm including my jetty config file:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<!-- =============================================================== -->
<!-- Configure the Jetty Server                                      -->
<!--                                                                 -->
<!-- Documentation of this file format can be found at:              -->
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax        -->
<!--                                                                 -->
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
<!-- and can be mixed in.  For example:                              -->
<!--   java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml           -->
<!--                                                                 -->
<!-- See start.ini file for the default configuraton files           -->
<!-- =============================================================== -->


<Configure id="Server" class="org.eclipse.jetty.server.Server">

    <!-- =========================================================== -->
    <!-- Server Thread Pool                                          -->
    <!-- =========================================================== -->
    <Set name="ThreadPool">
      <New class="org.eclipse.jetty.util.thread.ExecutorThreadPool">
      </New>
    </Set>

    <!-- =========================================================== -->
    <!-- Set connectors                                              -->
    <!-- =========================================================== -->

    <Call name="addConnector">
      <Arg>
          <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
            <Set name="host"><SystemProperty name="jetty.host" /></Set>
            <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
            <Set name="maxIdleTime">300000</Set>
            <Set name="Acceptors">2</Set>
            <Set name="statsOn">false</Set>
            <Set name="confidentialPort">8443</Set>
            <Set name="lowResourcesConnections">20000</Set>
            <Set name="lowResourcesMaxIdleTime">5000</Set>
          </New>
      </Arg>
    </Call>

    <!-- Uncomment this and enter your SSL config/credentials to enable https
    <Call name="addConnector">
      <Arg>
        <New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
          <Set name="Port">8443</Set>
          <Set name="maxIdleTime">30000</Set>
          <Set name="Acceptors">2</Set>
          <Set name="AcceptQueueSize">100</Set>
          <Set name="Keystore"><SystemProperty name="jetty.home" default="." />/etc/keystore</Set>
          <Set name="Password">PASSWORD</Set>
          <Set name="KeyPassword">KEYPASSWORD</Set>
          <Set name="truststore"><SystemProperty name="jetty.home" default="." />/etc/keystore</Set>
          <Set name="trustPassword">TRUSTPASSWORD</Set>
        </New>
      </Arg>
    </Call>
    -->

    <!-- =========================================================== -->
    <!-- Set handler Collection Structure                            -->
    <!-- =========================================================== -->
    <Set name="handler">
      <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
        <Set name="handlers">
         <Array type="org.eclipse.jetty.server.Handler">
           <Item>
             <New id="AkkaRestHandler" class="org.eclipse.jetty.servlet.ServletContextHandler">
               <Set name="contextPath">/</Set>
               <Call name="addServlet">
                 <Arg>se.scalablesolutions.akka.comet.AkkaServlet</Arg> <!-- BASICALLY A PIMPED Jersey ServletContainer -->
                 <Arg>/*</Arg>
               </Call>
             </New>
           </Item>
           <Item>
             <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
           </Item>
         </Array>
        </Set>
      </New>
    </Set>

    <!-- =========================================================== -->
    <!-- extra options                                               -->
    <!-- =========================================================== -->
    <Set name="stopAtShutdown">true</Set>
    <Set name="sendServerVersion">true</Set>
    <Set name="sendDateHeader">true</Set>
    <Set name="gracefulShutdown">1000</Set>

</Configure>     



--
Viktor Klang,
Code Connoisseur
Work:   www.akkasource.com
Code:   github.com/viktorklang
Follow: twitter.com/viktorklang
Read:   klangism.tumblr.com


Back to the top