Ok, I know that these emails are usually dismissed with the words:
"Gets us some proof from a profiler", and I will...gimme some time, in the
meanwhile, if anyone else wants to play with it.

well the story is that during heavy load tests of the session replication my
system my VMs always run out of memory.
What am I doing different than others, well, during my load tests I am not
using keep alive connections to achieve true round robin. I'm doing this by
setting method.setHttp11(false) in the Http client.

Running the test (attached, instructions below) I am hitting
http://localhost:8080/index.jsp (home page) and watching the memory grow and
grow and grow.

I am using a profiler and having somewhat of a hard time reading the output.
I am gonna download a trial of jprobe, see how that works out for me... I
will be back with results from that.

in the meantime, for those who want to see their memory grow here are the
instructions

My env:
Machine: PIII 1.6Ghz, 512MB Ram
OS: Redhat 8
VM: Sun JDK 1.4.2_02 (build 1.4.2_02-b03)

Instructions:
download the attached client.jar

execute:
java -cp testclient.jar;commons-httpclient.jar;commons-logging.jar
org.apache.catalina.cluster.test.client.MemTestClient http
://192.168.0.103:7080/index.jsp 100 100000 1000 false (exchange ; for : on
unix)

Watching the memory grow using Top, although it shouldn't increase at all.

Filip
package org.apache.catalina.cluster.test.client;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
public class MemTestClient {
    public MemTestClient() {
    }
    public static void main(String[] args) throws Exception {
        System.out.println("Usage org.apache.catalina.cluster.test.client.MemTestClient <url> <nrofthreads> <nrofrequests> <delay> <useHttp11>");
        String url = args[0];
        int nrofthreads = Integer.parseInt(args[1]);
        int nrofrequests = Integer.parseInt(args[2]);
        long delay = Long.parseLong(args[3]);
        boolean useHttp11 = Boolean.getBoolean(args[4]);
        for ( int i=0; i<nrofthreads; i++ ) {
            TestThread thread = new TestThread(useHttp11,url,delay,nrofrequests);
            thread.setDaemon(false);
            thread.start();
            Thread.currentThread().sleep(delay/3);
        }//for
    }
    
    static int threadCount = 0;
    static synchronized void incThread() {
        threadCount++;
        printStats();
    }
    
    static synchronized void decThread() {
        threadCount--;
        printStats();
    }
    static int[] codes = new int[1000];
    static int nrofrequests = 0;
    static long totalTime = 0;
    static long maxTime = Long.MIN_VALUE;
    static long minTime = Long.MAX_VALUE;
    
    public static void printStats() {
        StringBuffer stats = new StringBuffer("Memory test stats");
        stats.append("\n\tThread count=").append(threadCount);
        stats.append("\n\tNr Of Requests=").append(nrofrequests);
        stats.append("\n\tTotal time=").append(totalTime).append(" ms.");
        stats.append("\n\tAverage request time=").append(totalTime /
            (nrofrequests==0?1:nrofrequests)).append(" ms.");
        stats.append("\n\tMax request time=").append(maxTime).append(" ms.");
        stats.append("\n\tMin request time=").append(minTime).append(" ms.");
        for (int i = 0; i < codes.length; i++) {
            if (codes[i] > 0) {
                stats.append("\n\tNr of ").append(i).append(" codes=").append(
                    codes[i]);
            }
        } //for
        System.out.println();
                System.out.println(stats);
    }
    public static void addStats(int code, long time) {
        codes[code] = codes[code]+1;
        nrofrequests++;
        maxTime = Math.max(maxTime,time);
        minTime = Math.min(minTime,time);
        totalTime += time;
        if ( (nrofrequests % 100 ) == 0 ) {
            printStats();
        }//if
    }//addStats
    
    public static class TestThread extends Thread {
        boolean http11 = true;
        String url = null;
        long delay = 1000;
        int nrofreps = 100;
        public TestThread(boolean http11, String url, long delay, int nrofreps) {
            this.http11 = http11;
            this.url = url;
            this.delay = delay;
            this.nrofreps = nrofreps;
        }
        
        public void run() {
            incThread();
            int cnt = 0;
            HttpClient client = new HttpClient();
            GetMethod method = new GetMethod(url);
            method.setHttp11(http11);
            while ( cnt < nrofreps ) {
                try {
                    long start = System.currentTimeMillis();
                    int status = client.executeMethod(method);
                    method.getResponseHeaders();
                    method.getResponseBody();
                    long stop = System.currentTimeMillis();
                    addStats(status,stop-start);
                    Thread.currentThread().sleep(delay);
                } catch ( Exception x ) {
                    x.printStackTrace();
                }
                method.recycle();
                cnt++;
            }//while 
            decThread();
        }
    }

}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to