commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Cooper" <>
Subject Re: [FileUpload] Large file uploads are slow
Date Fri, 10 Mar 2006 23:00:21 GMT
On 3/10/06, C Rose <> wrote:
> Hi all
> I'm using commons-fileupload-1.1.jar to handle file uploads to a
> servlet. I expect typical file uploads to be around 40MB is size.
> However, the time taken to upload such files seems quite long.
> I have performed some profiling and have found that the call to
> ServletFileUpload.parseRequest() takes about 20 seconds for a 45MB file
> and accounts for over 80% of the time taken to upload the file. This is
> measured on a 600MHz P3 machine (yeah, I know...) with 512MB RAM
> running Linux, Sun's JVM and Tomcat. The machine is acting as both the
> client and the server and is under little additional load.
> I am using a DiskFileItemFactory, and the only thing I do to it is
> mandate that the ServletFileUpload object created by the factory does
> not have a limit on the size of the file being uploaded. The transfer is
> going via HTTPS.

I'm a little confused by this. First of all, the ServletFileUpload instance
is created by you, not by the DiskFileItemFactory. That factory creates
FileItem instances. Second, an unlimited file size is the default, so you
shouldn't be configuring anything if that's what you want. Perhaps you could
post the fragment of code that you use to set up the upload?

Does this upload time seem reasonable?

It seems longer than I would have guessed, but then again, I haven't used a
600MHz P3 for a while... ;-)

Is there anything I can do to speed things up?

Not knowing quite what you're doing now, it's a little hard to tell. But do
make sure that you're not mistaking the size threshold for the max size; if
you are, you'll be trying to keep the entire upload in memory, which is
certainly not what you want.

If parsing the request has to take so long, is it possible to perform
> this task after having returned a response to the client (e.g. start a
> new thread in which to call parseRequest() so that it appears as though
> I've serviced the request fully)---or am I right in thinking that an
> HttpServletRequest object will be 'invalid' after an HttpServletResponse
> is sent to the client?

Nope, you can't do that. The Servlet spec mandates that a request is
processed in its entirety on a single thread.

Martin Cooper

Thanks in advance
> C
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message