Advantage of Synchronous vs asynchronous in TCP socket connection

Async IO saves threads. A thread consumes (usually) 1MB of stack memory. This is the main reason to use async IO when the number of concurrent outstanding IO operations becomes big. According to my measurements OS scalability is not a concern until you get into the thousands of threads.

The main disadvantage is that it requires more development effort to make the same application work at the same level of reliability.

I have written about this tradeoff at length. Also: Should we switch to use async I/O by default?

It is objectively wrong advice to recommend to always use async IO.


Either mechanism will work. The main difference is that synchronous implies either blocking a thread that would otherwise do other useful things, or dedicating a thread to each connection. Either way, this does not scale very well. For simple applications with few or just one active connection, it might be okay.

But for any scenario where you need to handle any significant number of concurrent connections, the asynchronous APIs are the only ones that provide adequate performance. Also, in any interactive scenario (i.e. where you have to deal with user input and output), the asynchronous approach is more easily integrated with the user interface. That's especially true now that we have async and await in C#.