Tuesday, 27 October 2015

ASP.NET Tips #40 - Fully utilize all bottlenecks

While Async-Await habits work well, an architectural pattern can switch into higher gears. When processing multiple small jobs, consider splitting job parts into resource-specific chunks. Then create separate threads for each resource, and place memory buffers in between. The goal is to fully utilize whatever resource is the bottleneck on any given machine.

In the diagram below, for example, an application has four steps. It first reads a file from disk, does some processing on it, stores results in a database, and finally deletes the file. Each red box is a separate thread, and each vertical ‘swim-lane’ represents a particular resource. The process flows from top to bottom and uses queues as buffers between each resource-switch.

No comments :

Post a comment