<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=utf-8">
<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;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        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="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">That looks like a good solution, but not having any Kotlin in our build yet I'm hesitant to use it.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">It's also not clear from the email chain exactly how you schedule an additional task when a request is accepted/queued, especially if you don't have Kotlin Extensions available.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">I came up with a higher-level solution:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">- add X-Received-Time header to request in forward proxy / load balancer<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">- add servlet filter to check header and sendError(503) if it exceeds the configured timeout (though in my case the client will never receive this)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">It seems like there's still a core bug of not reacting to the client-side close though.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">James<o:p></o:p></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Stan Rosenberg <stan.rosenberg@acm.org>
<br>
<b>Sent:</b> 28 February 2020 19:18<br>
<b>To:</b> James Howe <jmh205@cam.ac.uk><br>
<b>Cc:</b> undertow-dev@lists.jboss.org<br>
<b>Subject:</b> Re: [undertow-dev] Worker queue timeout<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">On Thu, Feb 27, 2020 at 4:47 PM James Howe <</span><a href="mailto:jmh205@cam.ac.uk"><span style="font-size:12.0pt">jmh205@cam.ac.uk</span></a><span style="font-size:12.0pt">> wrote:<o:p></o:p></span></p>
</div>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<p class="MsoNormal">Under load, when the worker threads are saturated, new requests will be queued.<br>
Is there a way to timeout these requests, so that it doesn't waste time serving them later when the client has already given up?<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">If I understand correctly, the same issue was discussed in this thread: <a href="https://lists.jboss.org/pipermail/undertow-dev/2018-July/002231.html" target="_blank">https://lists.jboss.org/pipermail/undertow-dev/2018-July/002231.html</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">We ended up implementing custom logic based on CAS; here is the snippet in kotlin: <a href="https://gist.github.com/srosenberg/ed8d71d2f68379f909b1c4b8343807aa" target="_blank">https://gist.github.com/srosenberg/ed8d71d2f68379f909b1c4b8343807aa</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Thus, if a request takes longer than requestTimeoutMillis to service, the exchange is ended with StatusCodes.REQUEST_TIME_OUT<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">The performance overhead of CAS was negligible.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Best,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">stan<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">P.S. Sorry for the duplicate; first attempt to post was rejected by list server because I used the wrong reply address.<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>