Kbase P129466: How to simulate many simultaneous users in a WebSpeed Application
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  7/17/2008 |
|
Status: Verified
GOAL:
How to simulate many simultaneous users in a WebSpeed Application
GOAL:
How to simulate heavy load for a WebSpeed application
GOAL:
How to stress a WebSpeed application
FACT(s) (Environment):
All Supported Operating Systems
WebSpeed 2.x
WebSpeed 3.x
FIX:
Sometimes is difficult to know how an application would behave under a heavy load. This small program bellow is designed to help the WebSpeed users to see how the WebSpeed components are interacting and answer questions like:
1 - Is the Webserver able to deal with lots of requests at same time.
2 - Does the Webserver machine have some limitations to deal with lots of messengers? Windows, for instance, limits the maximum number of ports being used, and may fail to deal with a huge amount of cgiip.exe.
3- Is the agent answering fast enough?
4 - Does my application have some memory leaks that lets the agent instable after some time?
This program prompts for a URL and the total of users requesting at same time. It is up to the user to see the various WebSpeed logs and look for errors, as well the operating system logs and the broker status in the Progress Explorer tool to see how the agents are being used.
// copy from here up the end
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class StressWebspeed implements Runnable {
private int numThreads;
private int totalSuccess;
private int totalFailures;
String urlString;
int totalRequest;
public void getParameters() throws IOException {
System.out
.print("URL to Connect: ex: http://localhost/scripts/cgiip.exe/WService=wsbroker3/program.w?param1=val1¶m2=val2¶m3=val3:");
byte[] b = new byte[100];
int bytes = System.in.read(b);
urlString = new String(b, 0, bytes - 2);
System.out.print("Total of symultaneous requests: ");
bytes = System.in.read(b);
numThreads = Integer.parseInt(new String(b, 0, bytes - 2));
}
public void run() {
while(true) {
URL url;
try {
url = new URL(this.urlString);
HttpURLConnection conn = (HttpURLConnection) url
.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.connect();
BufferedReader r = new BufferedReader(new InputStreamReader(
conn.getInputStream()));
while (true) {
String ret = r.readLine();
if (ret == null)
break;
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void main(String str[]) {
StressWebspeed s = new StressWebspeed();
try {
s.getParameters();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thread t[] = new Thread[s.numThreads];
for (int i = 0; i < s.numThreads; i++) {
t[i] = new Threa.d(s);
t[i].start();
}
for (int i = 0; i < s.numThreads; i++) {
try {
t[i].join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
// end of the program
To run this program,
1 - Copy it and save in a file name StressWebspeed.java.
2 - Compile it using javac StressWebspeed.java.
3 - Run it using the command java StressWebspeed.
4 - Type the URL and press enter
5- Type the amount of simultaneous users and press enter.
.