0

I am testing my server application that receives Job objects and for this I have created a dummy client that sends my Server application as much amount of Job Objects as possible and for this I have created a Timer class as given below that sends Job objects to the server on constant basis. e.g. 2000 objects every second. But my client becomes slow when i exceed 2000 jobs per second.

Is there any other way to send large and fixed amount of jobs to the server?

If i create many Timer Instances then i have to synchronize the Socket which again makes things slow.

Is there any better solution to this problem with the help of which I can send thousands of job to the server without making things slow?

The code given here is a skeleton of Job etc and I just want to know other alternatives.

package comeOn;

import java.awt.event.ActionListener;
import javax.swing.Timer;
import java.io.*;
import java.awt.event.ActionEvent;
public class LoadGenerator extends Timer implements ActionListener{
    ObjectOutputStream outStream=null;
    int rndNumber;

    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }
public LoadGenerator(int interval,  ObjectOutputStream outStream,int rndNumber){
    super(interval,null);
    this.outStream=outStream;
    this.rndNumber=rndNumber;
    addActionListener(this);
    //this.setInitialDelay(1000);//start this timer afer 1 second.
}


@Override
public void actionPerformed(ActionEvent e){
    try {
        for(int i=1;i<=rndNumber;i++){
            Job job=new Job(100);
                outStream.writeObject(job);
                outStream.reset();
                outStream.flush();



            }

        }
    catch(Exception ex){}
}
class Job{
    int amount;
    Job(int amount){
        this.amount=amount;
    }
}
}
Yousaf
  • 27,861
  • 6
  • 44
  • 69
  • 1
    why don't you use a tool that was built for load testing: http://jmeter.apache.org/? – tavi Dec 06 '16 at 13:52
  • Jmeter can not send thousands of Jobs to my server It make things slow too plz read http://stackoverflow.com/questions/3528765/jmeter-max-thread-limit – faisal bahadur Dec 06 '16 at 14:20

1 Answers1

0

I googled my problem and I have found the answer here http://www.drdobbs.com/jvm/increase-java-serialization-performance/240159166?pgno=1