<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-GB link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Hi all,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’ve been using Undertow embedded in an Akka application and it is working great apart from a small issue when running load tests.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I’ve reduced the problem down to a small little demo application which I’ve attached below. It is in Scala but I can create a Java version if required.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I fire one million POST requests at Undertow and almost all succeed, however some never receive a response. The number that fail varies from 1 to 10.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Increasing the concurrency on the client and server side together and independently increases the number of failures. I’ve not yet seen any failures with no concurrency on the server side.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The HTTP handler callback is not invoked for the requests that fail. I’ve verified this by adding a counter before I call exchange.dispatch() and pass it on to the processing actor pool.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I don’t think I’m doing anything that is not thread-safe since Akka guarantees that actors do not execute concurrently. However the execution of the actor does move around a number of threads in the underlying Fork Join pool and I’m wondering if that would cause issues with Undertow?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Any suggestions for how I could debug this?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Michael<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Code to reproduce<o:p></o:p></p><p class=MsoNormal>==============<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>object UndertowTest {<o:p></o:p></p><p class=MsoNormal> def start(handler: HttpHandler) = Undertow.builder()<o:p></o:p></p><p class=MsoNormal> .addHttpListener(8888, "localhost")<o:p></o:p></p><p class=MsoNormal> .setHandler(handler)<o:p></o:p></p><p class=MsoNormal> .build()<o:p></o:p></p><p class=MsoNormal> .start()<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>class Responder extends HttpHandler {<o:p></o:p></p><p class=MsoNormal> override def handleRequest(exchange: HttpServerExchange): Unit = {<o:p></o:p></p><p class=MsoNormal> exchange.getResponseHeaders.put(io.undertow.util.Headers.CONTENT_TYPE, "text/plain")<o:p></o:p></p><p class=MsoNormal> exchange.getResponseSender.send("Hello world!")<o:p></o:p></p><p class=MsoNormal> }<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>class RequestHandler extends Actor with Loggable {<o:p></o:p></p><p class=MsoNormal> val handler = new Responder<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> override def receive = {<o:p></o:p></p><p class=MsoNormal> case exchange: HttpServerExchange =><o:p></o:p></p><p class=MsoNormal> handler.handeRequest(exchange)<o:p></o:p></p><p class=MsoNormal> }<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>object UndertowAkkaTest extends App {<o:p></o:p></p><p class=MsoNormal> val sys = ActorSystem()<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> // Changing the number here changes the number of actors handling incoming requests<o:p></o:p></p><p class=MsoNormal> val handlerPool = sys.actorOf(RoundRobinPool(4).props(Props(classOf[RequestHandler])))<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> UndertowTest.start(new HttpHandler {<o:p></o:p></p><p class=MsoNormal> override def handleRequest(exchange: HttpServerExchange): Unit = {<o:p></o:p></p><p class=MsoNormal> exchange.dispatch()<o:p></o:p></p><p class=MsoNormal> handlerPool ! exchange<o:p></o:p></p><p class=MsoNormal> }<o:p></o:p></p><p class=MsoNormal> })<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Apache Bench command to test<o:p></o:p></p><p class=MsoNormal>========================<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal># -c changes number of concurrent client side requests<o:p></o:p></p><p class=MsoNormal>ab -k -c 4 -n 100000 -p payload.json -T application/json <a href="http://localhost:8888/streams/demo/infrastructure/cpu">http://localhost:8888/streams/demo/infrastructure/cpu</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Data in payload.json<o:p></o:p></p><p class=MsoNormal>===============<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>{<o:p></o:p></p><p class=MsoNormal> "sampleTime": "2015-02-24T06:02:47",<o:p></o:p></p><p class=MsoNormal> "contributor": "3b8da322-ef8f-4f6b-93a3-a171dd794308",<o:p></o:p></p><p class=MsoNormal> "host": "some-host",<o:p></o:p></p><p class=MsoNormal> "process": "some-process",<o:p></o:p></p><p class=MsoNormal> "user": 35.7,<o:p></o:p></p><p class=MsoNormal> "kernel": 12.3<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div><br clear="both">
______________________________________________________________________<BR>
This email has been scanned by the Symantec Email Security.cloud service.<BR>
For more information please visit http://www.symanteccloud.com<BR>
______________________________________________________________________<BR>
</body></html>