title: Jetty hangs with 100% CPU on sun.nio.ch.FileDispatcherImpl.read0(Native Method)
body: <p>(update: it has nothing to do with file upload, more details at the bottom)</p>
  <p>I'm running <strong>jetty-distribution-9.0.6.v20130930</strong> server over <strong>jre-1.7.0-openjdk.x86_64</strong>, running on <strong>EC2 linux</strong> server. It's a backend to a mobile app that receives about 50k requests/day.</p>
  <p>About once a day, a thread hangs with 100% CPU, until I kill it (after running several hours on 100% CPU).</p>
  <p>JavaMelody shows the following call stack for the hung thread:</p>
  <p><img src="https://i.stack.imgur.com/2bE7k.jpg" alt="enter image description here" /></p>
  <p>Jetty HTTP connector definition, from etc/jetty-https.xml:</p>
  <pre><code>&lt;Call id=&quot;httpsConnector&quot; name=&quot;addConnector&quot;&gt;
    &lt;Arg&gt;
      &lt;New class=&quot;org.eclipse.jetty.server.ServerConnector&quot;&gt;
        &lt;Arg name=&quot;server&quot;&gt;&lt;Ref refid=&quot;Server&quot; /&gt;&lt;/Arg&gt;
          &lt;Arg name=&quot;factories&quot;&gt;
            &lt;Array type=&quot;org.eclipse.jetty.server.ConnectionFactory&quot;&gt;
              &lt;Item&gt;
                &lt;New class=&quot;org.eclipse.jetty.server.SslConnectionFactory&quot;&gt;
                  &lt;Arg name=&quot;next&quot;&gt;http/1.1&lt;/Arg&gt;
                  &lt;Arg name=&quot;sslContextFactory&quot;&gt;&lt;Ref refid=&quot;sslContextFactory&quot;/&gt;&lt;/Arg&gt;
                &lt;/New&gt;
              &lt;/Item&gt;
              &lt;Item&gt;
                &lt;New class=&quot;org.eclipse.jetty.server.HttpConnectionFactory&quot;&gt;
                  &lt;Arg name=&quot;config&quot;&gt;&lt;Ref refid=&quot;sslHttpConfig&quot;/&gt;&lt;/Arg&gt;
                &lt;/New&gt;
              &lt;/Item&gt;
            &lt;/Array&gt;
          &lt;/Arg&gt;
          &lt;Set name=&quot;host&quot;&gt;&lt;Property name=&quot;jetty.host&quot; /&gt;&lt;/Set&gt;
          &lt;Set name=&quot;port&quot;&gt;&lt;Property name=&quot;jetty.https.port&quot; default=&quot;8443&quot; /&gt;&lt;/Set&gt;
          &lt;Set name=&quot;idleTimeout&quot;&gt;30000&lt;/Set&gt;
        &lt;/New&gt;
    &lt;/Arg&gt;
  &lt;/Call&gt;
  </code></pre>
  <p>Jetty HTTPS configuration, from start.ini:</p>
  <pre><code>jetty.https.port=8443
  etc/jetty-https.xml
  </code></pre>
  <p>JVM version -</p>
  <pre><code>java version &quot;1.7.0_45&quot;
  OpenJDK Runtime Environment (amzn-2.4.3.2.32.amzn1-x86_64 u45-b15)
  OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)
  </code></pre>
  <p>a</p>
  <p><strong>Questions</strong></p>
  <ol>
  <li><p>What causes this?</p>
  </li>
  <li><p>Why timeouts are not triggered to kill these hanging threads?</p>
  </li>
  <li><p>How do I enable timeout of such scenarios?</p>
  </li>
  </ol>
  <p><strong>Update</strong></p>
  <p>Turns out it has nothing to do with file upload, it sometimes happens also in a different EC2 server (same configuration), and sometimes the two instances hang at <strong>exactly the same time</strong>, with the same call stack.</p>
  <p>The other server doesn't implement file upload, so this option is ruled out.</p>