File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Upload a file in multiple chunks paralelly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Upload a file in multiple chunks paralelly" Watch "Upload a file in multiple chunks paralelly" New topic

Upload a file in multiple chunks paralelly

amarnath nalumachu

Joined: Feb 10, 2005
Posts: 10
Hi All,

We have a web application that uses an applet to upload a file in chunks and transfers sequentially to the server and on the server side, a servlet receives the chunks. Now we are thinking of improving the overall performance. We are thinking of sending multiple chunks paralelly and servlet (some server side component) will assemble the chunks in right order (assume chunk order is passed) and creates the file the server side.
So my question, is this approach feasible? If feasible, what are the issues can arise with this approach? Please throw your ideas. Appreciate your help.

Brian Mozhdehi
Ranch Hand

Joined: Aug 17, 2006
Posts: 81
I cant think of a reliable way to do this. Why are you doing this in chunks? It seems like the only reliable and efficient way to do this is to upload the file in its entirety
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63532

Maybe I'm missing something but it seems to be pretty straight-forward. The individual threads, each uploading their particular chunk, could write their chunk onto the file system, and as each finishes checks to see if it's the last one and that all the other chunks have been written. That last thread would concatentate the files into one and remove the individual chiunks when done.

[Asking smart questions] [About Bear] [Books by Bear]
amarnath nalumachu

Joined: Feb 10, 2005
Posts: 10
I see following constraints or what ever.

1. We need to maintain the chunk order so that file assembly is proper on the server side. What is best way to identify a chunk number?
2. What if a chunk transfer fails, we need to mark the whole transfer as failure and ask the end user to transfer again.
3. Performance, there is lot of IO involved, as each chunk written to disk and later read the chunk and write a big file.

Any ideas.
I agree. Here's the link:
subject: Upload a file in multiple chunks paralelly
jQuery in Action, 3rd edition