tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samoilov_de...@emc.com
Subject corrupted stream
Date Tue, 25 Jul 2006 09:49:33 GMT
Hello,
We entercounter the problem that under high workload we get corrupted data
from Inputstream. The interesting moment that corruption has following
structure: 
imagine correct data as number of chunks - 1,2,3,4,5
received data - 3,4,3,4,5  (the first two chunks replaced by middle chunks).
The size of such chunks is exactly 1260 bytes. the corruption can occure in
the middle of file(e.g. 1,2,5,4,5). Number of corrupted chunks can vary
 
Here is situation description:
We have Tomcat 5.0.28(JVM: 1.5.0._06) and java servlet that works on it. The
servlet application receives binary files. The workload is high: more than
200 concurent users(and more than 2000 total). Every user uploads to server
number image files(size of each is about 700Kb). Tomcat has default settings
(see below). Clients connect to Tomcat directly.
Our code is (not exactly because it spared between different classes):
 
 
BufferedInputStream sis = null;
File f = new File(fileName);
BufferedOutputStream bos = null;
FileOutputStream fos = null;
long totalBytesReceived = 0L;
try {
 sis = new BufferedInputStream(m_request.getInputStream());
 byte[] buffer = new byte[FILE_UPLOAD_BUFFER_SIZE];
 File f = new File(fileName);
 fos = new FileOutputStream(f, true);
 bos = new BufferedOutputStream(fos);
                
 int bytesRead;
                
 while ((bytesRead = sis.read(buffer)) >= 0) 
 {
  bos.write(buffer, 0, bytesRead);
  totalBytesReceived += bytesRead;
 }
        } catch (IOException e) {
 ...
            }
        } finally {
            try {
                if (bos != null) bos.close();
                if (fos != null) fos.close();
            } catch (IOException e) {
                logger.warn("Close output stream throws an exception", e);
                throw new MyException(MyException.ERR_REQUEST_PROCESS, e);
            }
        } 
 
 
Can anybody suggest to use what we can do to resolve this situation.
 
Regards,
Denis
 
Additional info:
 
Tomcat runs on Windows 2003 (Windows Server 2003 Enterprise SP1 Intel Xeon
CPU 3.60 Ghz 2.00 GB of RAM). Tomcat(server.xml):
  <?xml version="1.0" encoding="utf-8" ?> 
 
<file:///C:/Documents%20and%20Settings/dsamoilov/Local%20Settings/Temporary%
20Internet%20Files/OLKE/server.xml#> - <Server>
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
/> 
  <Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> 
 
<file:///C:/Documents%20and%20Settings/dsamoilov/Local%20Settings/Temporary%
20Internet%20Files/OLKE/server.xml#> - <GlobalNamingResources>
  <Environment name="simpleValue" type="java.lang.Integer" value="30" /> 
  <Resource auth="Container" description="User database that can be updated
and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase" /> 
 
<file:///C:/Documents%20and%20Settings/dsamoilov/Local%20Settings/Temporary%
20Internet%20Files/OLKE/server.xml#> - <ResourceParams name="UserDatabase">
 
<file:///C:/Documents%20and%20Settings/dsamoilov/Local%20Settings/Temporary%
20Internet%20Files/OLKE/server.xml#> - <parameter>
  <name>factory</name> 
  <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value> 
  </parameter>
 
<file:///C:/Documents%20and%20Settings/dsamoilov/Local%20Settings/Temporary%
20Internet%20Files/OLKE/server.xml#> - <parameter>
  <name>pathname</name> 
  <value>conf/tomcat-users.xml</value> 
  </parameter>
  </ResourceParams>
  </GlobalNamingResources>
 
<file:///C:/Documents%20and%20Settings/dsamoilov/Local%20Settings/Temporary%
20Internet%20Files/OLKE/server.xml#> - <Service name="Catalina">
  <Connector acceptCount="100" connectionTimeout="20000"
disableUploadTimeout="true" port="8080" redirectPort="8443"
maxSpareThreads="75" maxThreads="150" minSpareThreads="25" /> 
  <Connector port="8009" protocol="AJP/1.3"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
redirectPort="8443" /> 
 
<file:///C:/Documents%20and%20Settings/dsamoilov/Local%20Settings/Temporary%
20Internet%20Files/OLKE/server.xml#> - <Engine defaultHost="localhost"
name="Catalina">
 
<file:///C:/Documents%20and%20Settings/dsamoilov/Local%20Settings/Temporary%
20Internet%20Files/OLKE/server.xml#> - <Host appBase="webapps"
name="localhost">
  <Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_log." suffix=".txt" timestamp="true" /> 
  </Host>
  <Logger className="org.apache.catalina.logger.FileLogger"
prefix="catalina_log." suffix=".txt" timestamp="true" /> 
  <Realm className="org.apache.catalina.realm.UserDatabaseRealm" /> 
  </Engine>
  </Service>
  </Server>
 
Tomcat
 
 

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