Jetty Timeout Problem When Serving Images

June 19, 2015 4.8k views
Java DigitalOcean Ubuntu


I'm running a Spring MVC app served by an embedded Jetty server on Ubuntu 14.04. I also have a MySql server running. I have added swap space to prevent out-of-memory errors according to this tutorial:

The droplet is the 5 USD/mo one with 512MB RAM, 1 core, 20 GB SSD. Performance is actually quite nice overall, but looking at the logs there are some hickups occasionally: java.util.concurrent.TimeoutException: Idle timeout expired: 300000/300000 ms

This exception is only thrown for images; such as "images/lowres/a.jpg", "images/lowres/b.jpg" and so on.

This error occurs almost exclusively on a page which serves 15 images, each of size about 35KB, so roughly 0.5MB.

What happens is that either all images load nicely in about 700-900 ms or 1-5 images are not loading, and these then proceed to time out, thus throwing the above IOException after 300000 ms (5 mintues).

I want to understand what is happening here, and how to fix it. Feedback is very much appreciated!

Just realized it would be a good idea to monitor the memory usage of my droplet to see if this is possibly a memory issue


  • Monitoring the memory usage using htop (while collapsing threads) shows that the JVM is using 70% of the Droplet memory (stable usage). The overall usage is 410/490 MB. So the JVM's usage would, according to htop, amount to: 0.7*490MB = 343MB.

    This is actually higher than what I have configured for the JVM:

    • Maximum heap size of 300MB (Xmx300m) and an initial heap size of 256MB (Xms256m).
  • There is a long discussion about this issue at:

    So far I have tried upgrading the Jetty version from 9.2.2.v20140723 to 9.2.10.v20150310, after which I have not been able to reproduce the issue.

    Will update this thread after some time has passed.

1 Answer

Upgrading Jetty version from 9.2.2.v20140723 to 9.2.10.v20150310 fixed the issue!

Have another answer? Share your knowledge.