Hello,

I faced another issue with my distributed OSGi application. My application 
should handle hundreds of requests per second whereby each request might need 
one second or more calculation time. But from my tests it seems that the OSGi 
framework only accepts 24 requests in parallel and queues the others.
I first thought that it is an error in my application so I commented out 
everything, just logged each service call, and set the thread to sleep to 
simulate the workload. It showed the same behaviour: 24 service calls were 
logged, then some wait time while the threads were sleeping, and then the next 
logs.
I although thought about a problem in my client (also an OSGi application), so 
I tried to access the service by using JMeter directly on the WSDL endpoint. 
The service behaved the same.
I also tested it in Felix and Equinox to see if there is any difference between 
the containers, but both showed the same behaviour.

The only explanation that came in my mind so far is the size of an internal 
thread pool that might be used by the OSGi container to schedule the requests. 
Does anybody know if there is a threshold for the maximum number of concurrent 
requests in OSGi and how I could increase it? Or do you have an idea what else 
could be the source of this behaviour?

Here is the code that I used to test the behaviour:
Service endpoint:
public AtomicInteger count = new AtomicInteger(0);
public MyResponse putRequest(MyRequest request) {
   System.out.println(this.count.incrementAndGet());

   try {
      Thread.sleep(10000);
   } catch (Exception e) {
      e.printStackTrace();
   }

   this.count.decrementAndGet();
   return new MyResponse("Hello from Server!");
}

Client:
                int id = 0;
for (int repeat = 0; repeat < 10; repeat++) {
   for (int i = 0; i < 50; i++) {
      LoadGeneratingThread t = new LoadGeneratingThread(id);
      t.start();
      id++;
   }
   try {
      Thread.sleep(1000);
   } catch (InterruptedException e) {
   }
}

The LoadGeneratingThread simply looks for the service using a 
ServiceTracker<S,T> and if it finds it, it calls the putRequest method.

Many thanks in advance,
Sven

Reply via email to