Search code examples
javaperformanceaesapache-commons-fileupload

Very slow read from the input stream fetched from the item - Commons FileUpload API


We are using Commons FileUpload API for handling the files uploading. We use a disk item factory where the file is written at a temp location and then we get an InputStream from the file item to encrypt the file and write it to the final location. My question is that the encryption, when we run it as a standalone application, runs in 25 seconds (for a 1 GB file). But when we use the same in the web application it is taking 12 minutes. And stranger thing is that this works fine on a different server (both the standalone and web application take the same time to encrypt). So, is there any issue with FileUpload API that causes some kind of a lock on the file even after it's completely written to the temp location, which in turn slows down our encryption?


Solution

  • The issue was that the encryption block of the code had log statements, so for each chunk that was encrypted there was a log being sent out, it was really fast once it was commented out.