Okay, everyone discussing this subject,
Looks like we need another explanation with a little more detail of our
testing and solution.
Once the user gets to a screen which displays a list of files to
download, they click on it and it sends the name of the file to the
servlet.
Heres the code snippet of reading/writing the file:

try
{

  FileInputStream fis = new FileInputStream(dataFile);
  BufferedInputStream bis = new BufferedInputStream(fis);
  OutputStream out = res.getOutputStream();

  // adding output buffering capabilities
  BufferedOutputStream bos = new BufferedOutputStream(out);
  DownloadThread dt = new DownloadThread(out, fis, getFileSize(dataFile)
);
  dt.run();

}
catch ( IOException io ) {

 throw new IOException( "File could not be sent: " + io.getMessage() );
}

//this is the dt.run() call

public void run() {

try {

// adding output buffering capabilities

  int count = totalsize / BLKSIZE;
  int datasize = totalsize / count;

  for ( int i = 0; i<count; i++ ) {
    datasize = fis.read();
    byte[] dataArray = new byte[ datasize ];
    out.write( dataArray );
  }
}

Using a 56M zipped file.

The MAIN problem when testing was that while one user was already
downloading, another user requesting the same file would get very LITTLE
bandwidth. (i.e first request downloaded at 600k/sec while the second
request got 40k/sec) We wanted an equal bandwidth for any amount of
users. OR, we ran into only one person getting the download, and the
other user hanging until that first download was finished.

Once the BufferedInput/OutputStream code was rewritten un-synchronized,
we tested up to five users all requesting the same file, and as each
request was processed the bandwidth equalled out for each
download.(145k/sec).
I'll be the first to admit I am not an expert in java, I was looking for
a solution in Tomcat3.2, perhaps servlet pooling, but I was unable to
find anyone else running in to the same problem. Then my teammate
studied the BufferedInput/Output class and decided to make a new class
that was unsynchronized and it worked so, I hope this ends the debate.
If we overlooked something and you have a better fix using
Linux/Tomcat3.2.1/jdk1.2.2 please let me know.

Thanks for everyones input,
Brian

"Christopher K. St. John" wrote:
>
> Zvika Markfeld wrote:
> >
> > apparently Brian meant that two
> > BufferedInputStream objects cannot access the same file simultaneously.
> > Meaning, it is the file that is actually synched, not the Stream object...
> >
>
>  I'd have to re-read the whole thread in detail to be
> sure, but I don't think that makes sense. I mean, if
> that were true, then there would be no way to fix it
> by using a "non-synchronized" BufferedInputStream, right?
>
>  And anyway, he said he was using Linux on a x86 box.
> I use Linux as one of my dev platforms, and unless he's
> using some really bizarre JVM, then I can guarantee you
> it doesn't work that way.
>
>  I suspect he was hitting random variations in how his
> threads were getting scheduled, resulting in one thread
> briefly getting most of the bandwidth. Or maybe they
> were running one set of tests with native threads, and
> another with green threads. There's not really enough
> data to draw a conclusion.
>
>  But it wasn't a problem with BufferedInputStream.
>
> --
> Christopher St. John [EMAIL PROTECTED]
> DistribuTopia http://www.distributopia.com
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to