We recently pitted a traditional server built using synchronous C# 4, ADO.NET and WCF with an equivalent solution built using asynchronous F#, ADO.NET and Google Protocol buffers over sockets. The characteristics of the two solutions really demonstrate the advantages of an asynchronous approach when using .NET. Specifically, our asynchronous solution was found to have the following advantages:
2× lower CPU usage¹
12× lower memory usage¹
90× lower max latency
10× higher max client connections
4× less code!
¹ with a constant stream of queries.
The basic ideas behind this real-world asynchronous server have already been covered in the following F#.NET Journal articles:
- Concurrent web crawling using asynchronous workflows
- An introduction to asynchronous workflows
- Distributed message passing
- Concurrent programming: TCP relay server
- Generic server architecture
Furthermore, the forthcoming .NET 4.5 will be the first to provide a fully asynchronous ADO.NET interface by adding a new ReadAsync method to read individual records from a database query asynchronously. This will make it possible to write fully asynchronous database code in .NET for the first time.