You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Steffen Heil <li...@steffen-heil.de> on 2006/09/23 03:27:28 UTC

Tomcat 5.5.17 has max 40 KB / sec

Hi

I use tomcat 5.5.17 and want to upload files. As this was *very* slow in
some cases, I wrote a benchmark servlet. Code is below.
I get the following statistics:

1. Running server on debian linux it accepts about 8.5 MB / sec. (Could
slowed down by VM overhead.)
2. Running server on windows xp it accepts about 3.5 MB / sec when the
client is connected over an rinetd redirection.
3. Running server on windows xp it accepts ONLY 40 KB / sec when the clinet
is connected directly.

This problem applies to Internet Explorer 6.0 as client only.
It does not occur so with Firebird (but still only about 2.4 MB / sec).

Using wireshark I found that the Internet Explorer is sending only 8 KB
(exactly) followed by an tcp PSH, which is not answered by the windows xp
machine running tomcat for 0.2 sec. That gives me exactly the 40 KB/sec.

I would say, my xp tcp stack is damaged, but it works with the same server,
when redirected through an external rinetd.

What can I do ?
Where can I start debugging ?
Anyone having similar problems ?

If possible, please also reply to me directly (CC).

Regards,
   Steffen



-->8-----------------------------------------------------------------------

package mypackage;

import java.io.InputStream;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class UpstreamBenchmark extends HttpServlet implements Runnable
{

	private long start = -1;

	private int total;

	private Thread thread;

	private final byte[] buffer = new byte[ 4096 ];


	public void run()
	{
		while ( !Thread.interrupted() ) {
			if ( start != -1 ) {
				long time = System.currentTimeMillis() -
start + 1;
				double speed = ( total / 1.024 ) / time;
				System.out.println( "speed: " + speed + "
kb/sec" );
			}
			try {
				Thread.sleep( 500 );
			} catch ( Throwable t ) {
				t.printStackTrace();
			}
		}
	}


	@Override
	public void destroy()
	{
		thread.interrupt();
		super.destroy();
	}


	@Override
	public void init()
		throws ServletException
	{
		super.init();
		thread = new Thread( this );
		thread.start();
	}


	@Override
	protected final void doPost( HttpServletRequest request,
HttpServletResponse response )
	{
		try {
			total = 0;
			start = System.currentTimeMillis();
			InputStream is = request.getInputStream();
			int read;
			while ( ( read = is.read( buffer ) ) != -1 )
				total += read;
			is.close();
			System.out.println( "read " + total + " bytes." );
		} catch ( Throwable t ) {
			t.printStackTrace();
		}
		start = -1;
	}

}