Hi Sergey!
I've taken your multi-threaded project and modified it so that each thread
sends a specific number of requests. What I am seeing is that the average
time is 100ms. Can you please confirm if this is correct? All my cores go
to 100% when I run this.
Note that the Response object is our own xml Response object, and not the
CXF one.
Regards
Kiren
package za.co.kiren.load;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import javax.ws.rs.core.MediaType;
import org.apache.cxf.jaxrs.client.WebClient;
import za.co.xxx.pams.messaging.response.Response;
public class MultiUserLoadTest {
private static final int NO_USERS = 10;
private static final int NO_REQUESTS_PER_USER = 1000/NO_USERS;
public static void main(String[] args) throws InterruptedException {
AtomicLong totalTime=new AtomicLong();
ThreadPoolExecutor executor = new ThreadPoolExecutor(NO_USERS,
NO_USERS, 0,
TimeUnit.SECONDS, new
ArrayBlockingQueue<Runnable>(NO_USERS));
CountDownLatch startSignal = new CountDownLatch(1);
CountDownLatch doneSignal = new CountDownLatch(NO_USERS);
for (int j = 0; j < NO_USERS; j++) {
executor.execute(new MultiUserLoadTest().new
Worker(totalTime,
startSignal, doneSignal));
}
startSignal.countDown();
doneSignal.await(120, TimeUnit.SECONDS);
executor.shutdownNow();
if (doneSignal.getCount() != 0) {
throw new RuntimeException("Not all threads done, must have
timed out?");
}
System.out.println("Average exec time ... " +
totalTime.intValue()
/ (NO_USERS*NO_REQUESTS_PER_USER));
System.out.println("No Users:"+NO_USERS);
System.out.println("NO_REQUESTS_PER_USER"+NO_REQUESTS_PER_USER);
}
class Worker implements Runnable {
private final AtomicLong total;
private CountDownLatch startSignal;
private CountDownLatch doneSignal;
private int count=0;
private String threadName;
public Worker(AtomicLong total, CountDownLatch startSignal,
CountDownLatch doneSignal) {
this.total = total;
this.startSignal = startSignal;
this.doneSignal = doneSignal;
}
@Override
public void run() {
threadName=Thread.currentThread().getName();
try {
System.out.println(Thread.currentThread().getName()+"
awaiting");
startSignal.await();
System.out.println(Thread.currentThread().getName()+"
started");
WebClient wc = WebClient.create(
"http://localhost:8080/RestTest/rest/test/xml",
"user", "passwordt", null);
wc.accept(MediaType.TEXT_XML);
for (int i = 0; i < NO_REQUESTS_PER_USER; i++) {
count++;
/* wc.replaceQueryParam("batchNumber",
((int) (1000 + Math.random() * 100)));*/
long l1 = System.currentTimeMillis();
Response response = wc.get(Response.class);
long l2 = System.currentTimeMillis();
total.getAndAdd(l2 - l1);
}
doneSignal.countDown();
System.out.println(Thread.currentThread().getName()+"
done");
} catch (Exception ex) {
System.err.println(threadName+" "+ex.getMessage());
;
throw new RuntimeException();
}
}
}
}
On Wed, Mar 28, 2012 at 12:20 PM, Sergey Beryozkin <[email protected]>wrote:
> Hi Kiren
>
> On 28/03/12 10:33, Kiren Pillay wrote:
>
>> Hi Sergey!
>>
>> With your code I'm getting 13 ms average on my Tomcat server and 34ms on
>> Jetty maven plugin (I was actually expecting the opposite).
>>
>> Against the String response url I'm getting 4ms on Tomcat and 5ms on
>> Jetty.
>>
>> I think now we're getting down to the level of differences in the quality
>> of our hardware, I've got an intel I5 (M 430 @ 2.27GHz) laptop with
>> plenty of RAM, you probably have a better machine. I'm running Java 7
>> update 3 on a linux 64bit Ubuntu 11.10 machine.
>>
>> I have I7 with few processors and plenty of memory, so that can explain
> some difference. Java6 & Ubuntu 11.04. Please try CXF 2.5.3-SNAPSHOT, that
> might help with saving few milliseconds too plus in case of JAXB - save on
> the pretty-printing 'expenses' which you already verified.
>
> What I think is that the server runtime is performing pretty well, the
> client runtimes have different qualities though and that can affect the
> performance measurements...
>
> Wonder how would JIXB perform :-)
>
> Cheers, Sergey
>
> Regards
>> Kiren
>>
>> On Tue, Mar 27, 2012 at 11:04 PM, Sergey Beryozkin<[email protected]**
>> >wrote:
>>
>> Hi Kiren
>>>
>>> On 27/03/12 13:09, Kiren Pillay wrote:
>>>
>>> Hi Sergey,
>>>>
>>>> Attached is a war file against which I am testing my client.
>>>>
>>>> great, thanks
>>>
>>>
>>> The test URLS
>>>
>>>> are given below together with the Jamon stats for a 1000 hits.
>>>>
>>>>
>>>> 1. Large response (27k)
>>>>
>>>> url="http://localhost:8080/****RestTest/rest/test/long/27000<http://localhost:8080/**RestTest/rest/test/long/27000>
>>>> <**http://localhost:8080/**RestTest/rest/test/long/27000<http://localhost:8080/RestTest/rest/test/long/27000>
>>>> >
>>>> "**;
>>>>
>>>> JAMon Label=myCodeTimer, Units=ms.: (Hits=1000.0, Avg=7.77,
>>>> Total=7770.0,
>>>> Min=4.0
>>>> tps:128.5512276642242
>>>>
>>>> 2. Small response
>>>>
>>>> url="http://localhost:8080/****RestTest/rest/test/short<http://localhost:8080/**RestTest/rest/test/short>
>>>> <http:**//localhost:8080/RestTest/**rest/test/short<http://localhost:8080/RestTest/rest/test/short>
>>>> >
>>>>
>>>> ";
>>>> JAMon Label=myCodeTimer, Units=ms.: (Hits=1000.0, Avg=5.454,
>>>> Total=5454.0,
>>>> Min=3.0, Max=37.0
>>>> tps:183.0831197363603
>>>>
>>>> 3. Dummy Response using the JAXB schema
>>>>
>>>> url="http://localhost:8080/****RestTest/rest/test/xml<http://localhost:8080/**RestTest/rest/test/xml>
>>>> <http://**localhost:8080/RestTest/rest/**test/xml<http://localhost:8080/RestTest/rest/test/xml>
>>>> >
>>>>
>>>> ";
>>>> JAMon Label=myCodeTimer, Units=ms.: (Hits=1000.0, Avg=15.381,
>>>> Total=15381.0,
>>>> Min=9.0, Max=542.0,
>>>> tps:64.96037417175522
>>>>
>>>>
>>>> With the following code:
>>>
>>> WebClient wc = WebClient.create("http://****
>>> localhost:8080/RestTest/rest/****
>>> test/xml<http://localhost:**8080/RestTest/rest/test/xml<http://localhost:8080/RestTest/rest/test/xml>
>>> >")**;
>>>
>>> wc.accept("text/xml");
>>> // warm up a bit
>>> for (int i = 0; i< 50; i++) {
>>> wc.get();
>>> }
>>>
>>> long total = 0;
>>> for (int i = 0; i< 1000; i++) {
>>> long l1 = System.currentTimeMillis();
>>> wc.get(Document.class);
>>> long l2 = System.currentTimeMillis();
>>>
>>> total += l2-l1;
>>> }
>>> System.out.println("Average: " + total/1000);
>>>
>>> I'm getting 10 millisecs average. Note I'm adding a Document reading just
>>> to eliminate any optimizations with webClient.get() where no actual read
>>> is
>>> done.
>>>
>>> Running the same code against
>>> http://localhost:8080/****RestTest/rest/test/long/27000<http://localhost:8080/**RestTest/rest/test/long/27000>
>>> <**http://localhost:8080/**RestTest/rest/test/long/27000<http://localhost:8080/RestTest/rest/test/long/27000>
>>> >
>>>
>>>
>>> (changing address, accept to text/plain, and wc.get(Document.class); to
>>> wc.get(String.class);)
>>>
>>> gives me 2 milliseconds average.
>>>
>>>
>>> Can you try the same code please ?
>>>
>>> Cheers, Sergey
>>>
>>>
>>> I've include our custom JAXB-enabled schema jar, the rest you can build
>>>
>>>> from
>>>> maven pom.xml.
>>>>
>>>> http://cxf.547215.n5.nabble.****com/file/n5597650/****
>>>> RestWarProject.tar.gz<http://**cxf.547215.n5.nabble.com/file/**
>>>> n5597650/RestWarProject.tar.gz<http://cxf.547215.n5.nabble.com/file/n5597650/RestWarProject.tar.gz>
>>>> **>
>>>>
>>>> RestWarProject.tar.gz
>>>>
>>>> Custom JAXB schema file:
>>>>
>>>> http://cxf.547215.n5.nabble.****com/file/n5597650/pams-core-**
>>>> xsd-server-1.3.0_ba_nemo-****SNAPSHOT.jar<http://cxf.**
>>>> 547215.n5.nabble.com/file/**n5597650/pams-core-xsd-server-**
>>>> 1.3.0_ba_nemo-SNAPSHOT.jar<http://cxf.547215.n5.nabble.com/file/n5597650/pams-core-xsd-server-1.3.0_ba_nemo-SNAPSHOT.jar>
>>>> >
>>>> pams-core-xsd-server-1.3.0_ba_****nemo-SNAPSHOT.jar
>>>>
>>>>
>>>> Regards
>>>> Kiren
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> View this message in context: http://cxf.547215.n5.nabble.**
>>>> com/CXF-Test-client-for-JAXB-****load-testing-****
>>>> tp5597650p5597650.html<http://**cxf.547215.n5.nabble.com/CXF-**
>>>> Test-client-for-JAXB-load-**testing-tp5597650p5597650.html<http://cxf.547215.n5.nabble.com/CXF-Test-client-for-JAXB-load-testing-tp5597650p5597650.html>
>>>> **>
>>>>
>>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>> --
>>> Sergey Beryozkin
>>>
>>> Talend Community Coders
>>> http://coders.talend.com/
>>>
>>> Blog: http://sberyozkin.blogspot.com
>>>
>>>
>>