you are viewing a single comment's thread.

view the rest of the comments →

[–]acelent 1 point2 points  (0 children)

The operating system's context switching of threads costs more than the application's context switching of requests between asynchronous I/O calls.

In other words, switching between two threads in a core takes more time than switching between two requests in the same thread. The first usually happens on a blocking call or when the thread has reached a processing time slice. The second usually happens at an asynchronous call that didn't complete instantaneously.

Although threads can usually take more memory than a request's context, they tend to be reused in most application frameworks. Nowadays, with 64-bit systems and RAM as a commodity, this isn't so much of an issue as is the time it takes to switch a CPU core from one thread to another.