Saturday, 5 November 2011

Scalable servers with async F#

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:

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.


Art said...

Win win win

nielsb said...

Cool!! Any plans on doing some articles about it?


object said...

Impressive! Some practical examples would be nice.

Flying Frog Consultancy Ltd. said...

@neilsb: This exact server was done under contract for a client but the basic ideas have already been covered in several 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
We also have a forthcoming article about servers with efficient compressed IO.