From bill at dartalley.com Fri Jan 4 00:53:13 2019 From: bill at dartalley.com (Bill O'Neil) Date: Fri, 4 Jan 2019 00:53:13 -0500 Subject: [undertow-dev] Delay execution of a HttpHandler Message-ID: Hello, I'm looking for a way to add artificial latency to requests and I'm having trouble finding a way that wouldn't require a blocking pool with 1 thread per request. What I would like to happen if possible. handler marks exchange as not ready (yield / pause) async runnable from another thread marks it ready to resume after some time next iteration of IO loop catches that it is ready and actually executes it now. public void handle(HttpServerExchange exchange) { if (firstExecution) { scheduledExec.schedule(() -> exchange.resume(), duration, unit); return; } next.handle(exchange); } Is something like this possible while staying on the IO threads the whole time other than the ScheduledExecutorService? I was thinking of using dispatch and dispatching back to the IO executor but I don't think that will do what I intend. The end goal would be a way to handle N requests with various delays built in to simulate latency without blocking connections. For instance if the worker pool has 30 threads and I submit 100 requests with a 1 minute delay followed by 1 request with a 10 second delay the final request should come back first. Thanks, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20190104/0c20bee2/attachment.html From ckozak at apache.org Fri Jan 4 09:40:20 2019 From: ckozak at apache.org (Carter Kozak) Date: Fri, 4 Jan 2019 09:40:20 -0500 Subject: [undertow-dev] Delay execution of a HttpHandler In-Reply-To: References: Message-ID: Perhaps some thing along these lines: public void handleRequest(HttpServerExchange exchange) throws Exception { exchange.dispatch(SameThreadExecutor.INSTANCE, () -> { exchange.getIoThread().executeAfter(() -> Connectors.executeRootHandler(next, exchange), duration, unit); }); } Best, Carter On Fri, Jan 4, 2019 at 12:53 AM Bill O'Neil wrote: > > Hello, > > I'm looking for a way to add artificial latency to requests and I'm having trouble finding a way that wouldn't require a blocking pool with 1 thread per request. > > What I would like to happen if possible. > > handler marks exchange as not ready (yield / pause) > async runnable from another thread marks it ready to resume after some time > next iteration of IO loop catches that it is ready and actually executes it now. > > > public void handle(HttpServerExchange exchange) { > if (firstExecution) { > scheduledExec.schedule(() -> exchange.resume(), duration, unit); > return; > } > next.handle(exchange); > } > > Is something like this possible while staying on the IO threads the whole time other than the ScheduledExecutorService? I was thinking of using dispatch and dispatching back to the IO executor but I don't think that will do what I intend. > > The end goal would be a way to handle N requests with various delays built in to simulate latency without blocking connections. For instance if the worker pool has 30 threads and I submit 100 requests with a 1 minute delay followed by 1 request with a 10 second delay the final request should come back first. > > Thanks, > Bill > _______________________________________________ > undertow-dev mailing list > undertow-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/undertow-dev From soria.gaby at gmail.com Tue Jan 22 01:46:02 2019 From: soria.gaby at gmail.com (Gaby Soria) Date: Mon, 21 Jan 2019 22:46:02 -0800 Subject: [undertow-dev] Advice on measuring filter performance overhead without networking activity Message-ID: Hi folks! I would really appreciate a piece of advice on how to do something. I'm working to measure the performance overhead adding the opentracing filter to a webapp (using java-web-servlet-filter library from https://github.com/opentracing-contrib/java-web-servlet-filter). Until now, I have a test, using JMH to start to deploy and simple servlet application and start the undertow server and test it using an http client. But I want to measure in the server side without considering the networking activity. How can I do that? My test, for now, is: https://github.com/gsoria/jmh-examples/blob/master/jmh-examples-java-servlet-filter/src/main/java/org/sample/BenchmarkSimpleServlet.java Thanks in advance -- Gabriela Soria -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20190121/1fd713c5/attachment-0001.html From sdouglas at redhat.com Tue Jan 22 16:47:05 2019 From: sdouglas at redhat.com (Stuart Douglas) Date: Wed, 23 Jan 2019 08:47:05 +1100 Subject: [undertow-dev] Advice on measuring filter performance overhead without networking activity In-Reply-To: References: Message-ID: I guess you could add a filter both before and after the filter you are interested in, have the first one stick the current time in the ServletRequest as an attribute, and the the one after the other filter can calculate how much time was spent. We don't really have any way of intercepting a filter in embedded Undertow. Stuart On Tue, Jan 22, 2019 at 5:47 PM Gaby Soria wrote: > Hi folks! > > I would really appreciate a piece of advice on how to do something. I'm > working to measure the performance overhead adding the opentracing filter > to a webapp > (using java-web-servlet-filter library from > https://github.com/opentracing-contrib/java-web-servlet-filter). > > Until now, I have a test, using JMH to start to deploy and simple servlet > application and start the undertow server and test it using an http client. > But I want to measure in the server side without considering the networking > activity. How can I do that? My test, for now, is: > > > https://github.com/gsoria/jmh-examples/blob/master/jmh-examples-java-servlet-filter/src/main/java/org/sample/BenchmarkSimpleServlet.java > > Thanks in advance > -- > Gabriela Soria > _______________________________________________ > undertow-dev mailing list > undertow-dev at lists.jboss.org > https://lists.jboss.org/mailman/listinfo/undertow-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20190123/58e9bfd5/attachment.html