Antonis
Antonis

Reputation: 1061

Stress test app with thread pool executor

Well i have the following problem. I want to stress test an application of mine that is deployed on a Tomcat server. The case i want to test is the following: a user uploads a file, the file is transcoded to another format and the new file is downloaded back to a user's device. I simulate every user with a thread(with three operations modeled as three methods). I create a thread pool executor of type newFixedThreadPool(30) and i execute the three methods in the run method of a class that implements Runnable, which is called in a for loop for 300 iterations for example(each iteration is a new user). In main:

ExecutorService executor = Executors.newFixedThreadPool(NTHREDS);

 for (int i = 0; i < 300; i++) {
    Runnable worker = new MyRunnable(i);
        executor.execute(worker);
    }
executor.shutdown();

and in MyRunnable class

public void run() {
testPostFile(); testPSXFileRename(); testGetFile(); }

    public static void testPostFile() {}
    public static void testPSXFileRename() {}
    public static void testGetFile();

Is my approach correct? Or are there tricky parts that i missed

Upvotes: 1

Views: 4210

Answers (1)

Sean
Sean

Reputation: 7737

It appears you are trying to do both load testing and a bit of unit testing. Try and separate your tasks.

When it comes to load/stress testing, JMeter is a good open source way to perform your load testing. JMeter allows you to record a script, and then you can simulate load based on that. You can search youtube for some getting started videos.

If you are doing unit testing, use JUnit.

Let your unit tests make sure things are functionally correct, and the load testing to determine how your server reacts under load.

Upvotes: 2

Related Questions