• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to resolve Java's I/O Capabilities for parallel High-Performance ?

 
L JW
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,
I hava a web site to provide file/image download.for these,I write the file stream to response stream,but I found in the high parallel envionment,all the thread of web contrainer blocked by java I/O.
follwing is my code:

FileInputStream fis = new FileInputStream(storeFile);
FileCopyUtils.copy(new BufferedInputStream(fis), new BufferedOutputStream(response.getOutputStream()));

please give some advice.

Thanks!
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never faced this problem before.Just a guess

FileInputStream fis = new FileInputStream(storeFile);

When your program runs many request threads then are you sharing the storeFile or for each and everyfile you have different instances of storeFile.When you make a File object , it consumes some system resource (File descriptor) and this is fixed to some upper limit.You might be running out of this descriptors.
 
L JW
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply,Thare are many user request download same file,how can I resolve this problem?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15713
73
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could add a cache mechanism to your web application, so that the system doesn't need to load the same file from disk to memory 100 times when 100 users are downloading the same file.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!