The Task Parallel Library (TPL) introduced in Microsoft. NET Framework 4 enables application developers to create solutions that take advantage of the parallel processing capabilities of multi-core computers. In many cases, however, the ability to vertically expand (adding multiple cores) is constrained by a number of factors, including cost and host-hosting constraints. In this case, if you need to expand your capabilities, you can allocate data to the server array; Cloud Hosting is an example of this. In this article, I will describe a set of key aspects of a conceptual solution, including implementation, to accomplish this scenario by using the many new features of the. NET Framework 4.5.
Basic Prerequisites
The method that I am going to describe requires a variety of technologies other than TPL, including:
Task Parallel Library (TPL)
Windows Communication Foundation (WCF)
Managed Extensibility Framework (MEF)
Please note that I discuss these aspects only in the issue that I am trying to solve. I assume you know a lot about these technologies.
Remote task Client, Task Coordinator, and Task execution node
The remote task client is the client side layer that hides the complexity generated by the semantics of using the distributed environment. The remote task client interacts directly with the task Coordinator, and then the Coordinator becomes the entry point to the underlying infrastructure. Overall, the task Coordinator has the following attributes:
The task Coordinator is the only point of contact that communicates with the client.
The coordinator exposes the necessary services to request the execution of tasks on an extensible platform and to cancel specific tasks.
The coordinator handles the constraints and queues of task execution requests and supports the healthy operation of the environment.
The task execution node is the host on which the task runs the process. The actual implementation of the tasks performed by TPL resides in the task execution node.
Here are the logical layers and the main aspects and information flow:
The remote task client requests that one or more tasks be performed.
The task coordinator submits the request to the task execution node.
The task Execution node performs the task and updates the status of each request in the task Coordinator.
The Task coordinator updates the client using the execution results of each request.
The task execution node resides behind the load balancer, so you can add more nodes as needed to enable horizontal scaling.
Figure 1 shows the logical layer and the flow of information.
Figure 1 Horizontal Scaling tasks
Notice how the Task Execution node updates the task Coordinator, and then the task coordinator updates the remote task client. I'm going to describe an implementation that is based on two-way communication between the client and the task Coordinator, and the two-way communication between the task Coordinator and the Task execution node. According to WCF definitions, this means that a duplex channel is used to make the task execution node callback to the task Coordinator, and then the task Coordinator performs the same operation to update the client. I'll show you how to implement this two-way communication using WebSockets. The WebSockets transport is implemented as a new binding to the. NET Framework 4.5 and can be used on Windows 8. For more information on this binding, please visit Bit.ly/solniu.