<div dir="ltr"><div><font face="monospace, monospace">&gt; I am not 100% sure what you are trying to test here</font></div><div><font face="monospace, monospace">&gt; The global state protected by a sync lock will not perform very well, </font></div><div><font face="monospace, monospace">&gt; and does not in any way represent the way the majority of web applications manage their state.<br></font></div><div><font face="monospace, monospace">&gt;<br></font></div><div><font face="monospace, monospace">&gt; What sort of real world situation you are trying to simulate here?</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><span style="font-family:monospace,monospace">i&#39;ve written a java database engine - the sync lock is simulating this database. initially i&#39;m focusing on low-end VPS hosts, so i&#39;m more interested in efficiency than peak performance. i&#39;m just trying to get a baseline (as opposed to a benchmark) of what async is capable of on various platforms</span><br></div><font face="monospace, monospace"><br></font><font face="monospace, monospace">my database is (kilim) fiber-based and can handle far more concurrent queries than the OS can support threads, so my motivation is to verify that the web server can support a comparable number of open connections. this isn&#39;t apples to apples - in the real case there could be many more connections and much more delay, but this seems like a good start</font><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><font face="monospace, monospace">here&#39;s the faster version:<br><a href="https://github.com/nqzero/jempower/blob/master/utow/src/main/java/UtowAsync2.java">https://github.com/nqzero/jempower/blob/master/utow/src/main/java/UtowAsync2.java</a><br><br>it still has the global lock, but does the actual processing in multiple threads. the repository has versions for some other platforms as well (jetty, comsat and kilim)<br><br>comparing the 3 undertow handlers<br>124k req/s - sync (from TechEmpower benchmark)<br> 92k req/s - async (reply inside lock)<br>118k req/s - async2 (with 3 threads)<br><br>this is on an i3, and i&#39;m testing with ab (2 instances are required to saturate the sync and async2 versions) at various concurrency levels (mostly 1000 - 10000), and the TechEmpower version results in some receive errors at lower concurrencies than the async versions<br><br></font><div><font face="monospace, monospace">i also need an example of asynchronous usage so i can tell people how to build a webapp using my database with undertow, so i want to be doing the &quot;right&quot; things - hence the simple async version. thanks for the feedback to my questions. if you can point me to a simpler example of async undertow (that doesn&#39;t involve a thread-per-connection), i&#39;m happy to use that instead</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">my conclusion is that for undertow, using async adds at most an insignificant overhead, perhaps something on the order of 5% throughput and can be implemented easily, using the dispatch/getResponseSender pair</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">does this sound right to you ?</font></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">any idea how much memory is allocated for each </span><span style="font-family:monospace,monospace">outstanding request ? i&#39;m assuming it is much less than the memory needed for an OS thread (using top i see a 40k concurrency delta -&gt; a delta of 300M in resident memory usage, but realize that this is a crude technique)</span></div><div><span style="font-family:monospace,monospace"><br></span></div><div><font face="monospace, monospace">if you&#39;d like to see any changes or want to add a caveat so i don&#39;t misrepresent undertow, add a pull request or just let me know - my goal is to advocate for async while being (reasonably) platform agnostic</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><br></font></div><div><br></div></div>