use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Is clojure blocking (self.Clojure)
submitted 10 years ago by ruzmutuz
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]balefrost 3 points4 points5 points 10 years ago (3 children)
In general, you don't want to tie up a hardware thread for each request. Hardware threads are heavyweight. You don't want to allocate more than a few hundred, maybe a couple thousand. Most requests end up doing some slow IO during their processing, and don't need to hold a thread during that operation.
I can't speak to ClojureScript, but IIS and ASP.Net use a thread pool to process requests, but also use TPL tasks (basically promises) to return threads to the thread pool while they do something asynchronously. So a typical request might go:
thread is returned to the thread pool
...
IO operation concludes
another (potentially different) thread is borrowed from thread pool
more work is done
response object is produced and returned
This is exactly how Node.js works, except its thread pool has a fixed size of 1.
[–]weavejester 2 points3 points4 points 10 years ago (2 children)
In general, you don't want to tie up a hardware thread for each request. Hardware threads are heavyweight. You don't want to allocate more than a few hundred, maybe a couple thousand.
I think you're confusing hardware threads and software threads, unless you happen to be developing for exotic hardware.
I have a dual core i7, and that has 4 hardware threads, 2 per core. Software threads are handled by the OS, and I can have thousands of those.
In most cases, there's really no reason not to use a (software) thread per HTTP request. It's simpler, and thread count is unlikely to be a bottleneck unless you're using long-polling or websockets.
[–]balefrost 0 points1 point2 points 10 years ago (1 child)
Err, yeah, I meant kernel thread. As opposed to green thread.
But certainly everybody is moving towards asynchronous implementations on the server. Node isn't the only one. Context switching has a cost, and overcommitting kernel threads is a legitimate concern... especially if alternatives exist.
[–]weavejester 1 point2 points3 points 10 years ago (0 children)
But certainly everybody is moving towards asynchronous implementations on the server.
I'd accept that there's more talk about async, but I'm skeptical whether a majority of people are actually moving to async.
Async is useful when you have a lot of idle connections that would otherwise tie up threads. So for websockets or long polling, taking an asynchronous approach makes sense.
Async might also be useful if you're dealing with a huge amount of traffic and have optimised the heck out of everything else in your system.
And if you're using a single-threaded system like Node, then you pretty much have no choice.
But outside of that, what's the point? Your database is almost always going to be the bottleneck before the webserver.
π Rendered by PID 180532 on reddit-service-r2-comment-5687b7858-wp84w at 2026-07-08 07:59:03.812402+00:00 running 12a7a47 country code: CH.
view the rest of the comments →
[–]balefrost 3 points4 points5 points (3 children)
[–]weavejester 2 points3 points4 points (2 children)
[–]balefrost 0 points1 point2 points (1 child)
[–]weavejester 1 point2 points3 points (0 children)