2 Replies Latest reply: Aug 18, 2010 4:13 AM by 843790 RSS

    HELP -ZipOutputStream performance is not consistent across servers


      I have a pretty standard code that zips one folder in a zip file using ZipOutputStream. The folders that are zipped are 2 GB in size and consists of TIFF images files.

      We are currentinly in the testing phase and notice very inconsistent performance issues with the Zipping module. On the integration server, to zip 2 GB of data, the zip module took 5 minutes. However, when the same zip code runs on the staging server, it takes 20 minutes. Both the servers are the same in RAM capacity and processing powers. The size of the data is also the same: 20 GB.

      Can anyone help me understand what could be the issue such taht the performance is so detrimental when movingfrom one server to another.

      The only difference between the two servers is that on the integratoin server there is 20 GB of free harddisk space and on the staging server there is only 8 GB of hard disk space. Is it possible that because of the less disk space on staging, the OS itself is taking a few seconds extra on each write to allocate the space. Possibly disk fragmentation also may be a factor.

      For your reference, the zip code is as follows:
      public boolean createZip(File sourceToZip,String zipDestination, String zipFileName) throws IOException
                 boolean result=false;
           // Check that the directory is a directory, and get its contents
           File d = sourceToZip;
           if (!d.isDirectory())
            throw new IllegalArgumentException("Not a directory:  "
                + sourceToZip);
           String[] entries = d.list();
           byte[] buffer = new byte[4096]; // Create a buffer for copying
           int bytesRead;
           ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipDestination+"/"+zipFileName));
           for (int i = 0; i < entries.length; i++) {
            File file = new File(d, entries);

           if (file.isDirectory())
           continue;//Ignore directory
           FileInputStream in = new FileInputStream(file); // Stream to read file

           ZipEntry entry = new ZipEntry(file.getName()); // Make a ZipEntry

           out.putNextEntry(entry); // Store entry
           while ((bytesRead = in.read(buffer)) != -1)
           out.write(buffer, 0, bytesRead);
                catch(IOException e)
                     throw e;
                return result;

      If anyone has any ideas let me know Thanks.