Large images timeout when image effects are applied to them, can cause CPU spike
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
If a large image is added to a Confluence page, and then an image effect is attempted (such as drop shadow), the transformation can timeout. While it's running, it can also cause CPU spikes and take down Confluence in certain situations.
Confluence will display:
The following appears in the atlassian-confluence.log
WARN [http-nio-8443-exec-17] [confluence.image.effects.ImageFilterServlet] transformAndRespond Timed out while doing the transform
-- referer: https://localhost:8443/conf624/pages/resumedraft.action?draftId=5275657&draftShareId=7b1a548a-bd7d-4919-a0ef-08faf271b2b1 | url: /conf624/download/thumbnails/5275656/myimage.jpg
| traceId: f6ea544c01c2fbbf | userName: admin
java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(FutureTask.java:205)
at com.atlassian.confluence.image.effects.ImageFilterServlet.transformAndRespond(ImageFilterServlet.java:273)
at com.atlassian.confluence.image.effects.ImageFilterServlet.writeTransformToResponse(ImageFilterServlet.java:188)
at com.atlassian.confluence.image.effects.ImageFilterServlet.doGetInTransaction(ImageFilterServlet.java:155)
at com.atlassian.confluence.image.effects.ImageFilterServlet.lambda$doGet$0(ImageFilterServlet.java:132)
There is a bug filed for this: CONFSERVER-55200 - Unable to apply image effects to dimensionally large images.
Cause
Confluence will attempt to apply effects to any image that is under 16MB in size. It will wait for 12 seconds for the transformation to complete, at which point it will time it out. This process is very CPU intensive, so the more resources your server has, the less chance it will run into this problem, unless your server is already very busy. In busy servers, this additional CPU usage can have a destabilising impact.
Workaround
You can add a JVM parameter that specifies the maximum file size that should be allowed to have an image effect applied to it. The below parameter will set a max size of 1MB. The default is 16MB.
-Datlassian.image_filter.transform.max_data_size=1000000