Hi, I am trying to replace one servlet serving huge files by a webservice. When request comes in, the servlet opens InputStream to the file blob in database, read from the input stream and write to the http output stream. When client starts pulling the data it comes straight from the input stream of the servlet (pure streaming). In which case the Servlet can handle 100s of clients because the Servlet threads are not trying to load the whole file into memory on the server side and just sending down the data when it is read from the client side.
Now I am trying to replace the servlet code by a web service. I am using DataHanlder for attachements. We have big files in database (each 10MB or more). When the client call my service downloadfile(fileName) I need to pull it from the database and create a datahandler and return to the client. My concern is what will happen if 100 clients request the all big files (say each 10 MB in size) using downloadFile() service. My question here is how the datahandler works, will it read all the file contents from file blob from database and store in memory before we return it to the client? Looks like it is because my tomcat is running out of memory when I tried 20 client threads in parallel requesting for big files. How can I solve the problem? Following is my code snippet Blob file_blob = rs.getBlob(1); ByteArrayDataSource bds = new ByteArrayDataSource(file_blob.getBinaryStream(), "application/octet-stream"); DataHandler data_handler = new DataHandler(bds); return data_handler; Thanks in advance Yuva
