Re: [Simpleweb-Support] Asynchronous services get blocked
Brought to you by:
niallg
From: Alvaro G. <alv...@gm...> - 2013-04-30 09:51:06
|
Hi, I would belive what you say but, I have another but simpler test. I can send you the code if you want a simple Asynchron invokation...just an empty task with a simple sleep. If you send 10 request from "Soap-ui" (Loadtest) you will se that the simpleframe get blocked. We use for logging log4j, but it should not matter. Just try it before you say anything I think you test it yourself. - Klient Soap-ui Loadtest 10 request the code: public class TestAsynchronousServiceContainer implements Container { private final ExecutorService executor; public class TestTask implements Runnable{ public void run() { long recievedTime = System.currentTimeMillis(); try { System.out.println("Timeout in millis " + 10000); long timeOutStarted = System.currentTimeMillis(); System.out.println("Timeout startade " + new Date(timeOutStarted)); // pauseReqAnswer(messageTimeOut); Thread.sleep(10000); System.out.println("The response time was: " + recievedTime + " ms "); } catch(Exception e) { e.printStackTrace(); } } } public TestAsynchronousServiceContainer() { this.executor = Executors.newCachedThreadPool(); // this.executor = Executors.newFixedThreadPool(100); } @Override public void handle(Request request, Response response) { System.out.println("receiving request " + request.getAddress().toString()); // Task task = new Task(request, response, cfg); TestTask task = new TestTask(); executor.execute(task); System.out.println("Executing task"); } } public static void main(String[] list) throws Exception { Container container = new TestAsynchronousServiceContainer(); Server server = new ContainerServer(container); Connection connection = new SocketConnection(server); InetSocketAddress address = new InetSocketAddress(8888); String hostName = getLocalHostName(); LOG.info("HTTP SERVER STARTING at url: http://" + hostName + ":" + cfg.getServerPort()); connection.connect(address); } I have had 3 developers with about 10 years experience and every one of them have got the same result. Remember they run a SOAP-UI klient 2013/4/30 Niall Gallagher <gal...@ya...> > Hi Alvaro, > > This is simply not true, there is something wrong with your test code, not > sure what exactly but I would recommend you take a closer look at your code. > > Niall > > --- On *Tue, 30/4/13, Alvaro Guillermo <alv...@gm...>* wrote: > > > From: Alvaro Guillermo <alv...@gm...> > Subject: [Simpleweb-Support] Asynchronous services get blocked > To: Sim...@li... > Received: Tuesday, 30 April, 2013, 1:38 AM > > > nice and easy to use but there seems to be a problem when you use several > thread. I have a timeout for certain type of request the code is quite > straightforward. I looks like the example, ie. > > > this.executor = Executors.newCachedThreadPool(); > @Override > public void handle(Request request, Response response) > { > > LOG.info("receiving request " + request.getAddress().toString()); > Task task = new Task(request, response, cfg); > executor.execute(task); > LOG.info("Executing task"); > } > > There is two differences In the Task compared to the examples in the > homepage, > > 1)I have a Thread.sleep(millis) > > 2) I used Executors.newCachedThreadPool > > I tried the same sniper code outside the simpleframework and It worked > fine. The problem is that it seems that when you have big loads of > requests the simpleframework get a blocked handling like 3 requests at the > time, ie. and it does not handle more request until the current Threads > have runned completetly. > > In my eyes it should continue to handle requests even if some threads are > sleeping, if you are using threads, the same sniper code outside > simpleframework works fine so I don't think it has to do with the code. I > tried also without Thread.sleep but I let the "task" do a lot of things > that took about 10 seconds to finish. The same problem here simpleframework > get blocked until it was finished with the current tasks, despite the fact > it was supposed to run asynchronously. The same code works fine outside > simpleframework, when I put it in a "main" class instead. > > I need some hints och help with this issue. > ------------------------------ > > > > -----Inline Attachment Follows----- > > > ------------------------------------------------------------------------------ > Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET > Get 100% visibility into your production application - at no cost. > Code-level diagnostics for performance bottlenecks with <2% overhead > Download for free and get started troubleshooting in minutes. > http://p.sf.net/sfu/appdyn_d2d_ap1 > > -----Inline Attachment Follows----- > > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li...<http://mc/compose?to=Sim...@li...> > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > > > ------------------------------------------------------------------------------ > Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET > Get 100% visibility into your production application - at no cost. > Code-level diagnostics for performance bottlenecks with <2% overhead > Download for free and get started troubleshooting in minutes. > http://p.sf.net/sfu/appdyn_d2d_ap1 > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > > -- Alvaro Rubio M. Sc. (Computer and System sciences) Swedish Tax Agency, Swedish Enforcement Authority (Skatteverket, kronofogden), Stockholm Phone +46 (0)767252832 Mobile +46 (0)720010966 |