Reputation: 492
I'm building a web application in Clojure, using luminus and ring. I build my app using lein uberjar, and it is then built with the undertow server.
My question is, when are requests to the app run in separate non-blocking threads?
I have tested the concurrency of the app by doing requests to a page that does (Thread/sleep 20000)
. If I access this page at the same time in two tabs in Chrome, the second tab is not loaded until after about 20 seconds after the first tab has been loaded. Thus, these two accesses do not seem to create different threads.
However, if I access the page in one Chrome tab and one Safari tab, both tabs complete at the same time. And if I use two Safari tabs, they complete at the same time.
How does this work? When does undertow create separate threads for each request?
EDIT: This behavior is not related to Undertow or Clojure, but rather Chrome, as pointed out by @Piotrek Bzdyl. See comments below.
Upvotes: 1
Views: 233
Reputation: 13175
I think you are observing Chrome behaviour - it opens a single connection to a given URL across the whole Chrome application - if you open the same URL in different tabs, Chrome will first open and download a resource in one tab and once done it will the same in another tab.
To test concurrency in your application you need to use other tools. You could try running multiple curl
commands or even better ab
tool:
ab -c 3 -n 3 https://www.google.com/
Upvotes: 1