Dynamic Image Caching with Java

Posted by zteater on Stack Overflow See other posts from Stack Overflow or by zteater
Published on 2012-12-17T04:06:36Z Indexed on 2012/12/17 5:03 UTC
Read the original article Hit count: 121

Filed under:
|

I have a servlet with an API that delivers images from GET requests. The servlet creates a data file of CAD commands based on the parameters of the GET request. This data file is then delivered to an image parser, which creates an image on the file system. The servlet reads the image and returns the bytes on the response.

All of the IO and the calling of the image parser program can be very taxing and images of around 80kb are rendering in 3-4000ms on a local system.

There are roughly 20 parameters that make up the GET request. Each correlates to a different portion of the image. So, the combinations of possible images is extremely large.

To alleviate the loading time, I plan to store BLOBs of rendered images in a database. If a GET request matches one previously executed, I will pull from cache. Else, I will render a new one. This does not fix "first-time" run, but will help "n+1 runs".

Any other ideas on how I can improve performance?

© Stack Overflow or respective owner

Related posts about java

Related posts about servlets