The nature of WCF concurrency (concurrency)

Source: Internet
Author: User
Tags resource

Simultaneous processing of multiple service invocation requests---the same service instance context (InstanceContext)

Introduction

The essence of service is to provide a function that the service consumer expects, the value of the service is embodied in two aspects: the quality of the service itself and the number of concurrency of the boarding service, and the second element is the attention of concurrent (the). WCF services are hosted in a resource-constrained environment, and to maximize service utility, you need to consider how to leverage existing resources to achieve maximum throughput (throughput). Increase throughput an important way to get a hosted service Instance is to be able to handle concurrent access from each client (Service Broker) at the same time. WCF implements a complete set of concurrency control systems that provide you with different concurrency patterns.

I often say that software architecture is a trade-off of the art, need to take into account a variety of conflicting factors, to find an optimal combination of ways. Increasing the amount of concurrent traffic allowed by a single service instance can increase overall throughput, a theory that relies on the assumption that the resources available to the server are unlimited. We know that this assumption will not be tenable under any circumstances. If our concurrency exceeds the critical point that the server can withstand, the entire server will crash. As a result, WCF needs to allow a single service instance to handle multiple requests received concurrently, as well as set a gate to control concurrent numbers. WCF's flow limit (throttling) system creates this gate for you.

Starting from this article, I will publish a series of articles on the WCF Concurrency architecture in-depth analysis, first of all, to see the basic introduction of concurrency.

One, the same service instance context handles multiple service invocation requests simultaneously

Concurrency means that multiple parallel operations work on an identical resource or object, or that the same resource or object simultaneously deals with multiple concurrent requests. For WCF concurrency, the "resource or object" here refers to the service Instance that hosts the final execution of the service operation. While WCF encapsulates a service instance in a known instance context (InstanceContext) object, concurrency in WCF refers to the same service instance context handling multiple service invocation requests at the same time.

WCF server-side framework a primary task is to distribute the received service invocation request to the active service instance, invoke the appropriate service operation, and return the execution result. In other words, the execution of service operations will eventually be implemented on a specific service instance. The 9th chapter of WCF Technical Analysis (Volume 1) makes an in-depth analysis of WCF's instantiation mechanism, from which we know that in the WCF service-side framework, the active service instance is not alone, but is encapsulated in a known instance context (InstanceContext) object. WCF provides three different instance context modes (Per-call, Per-session, and single) to implement different service instance context delivery mechanisms.

Therefore, the WCF concurrency framework solves how to efficiently handle multiple service invocation requests that are distributed to the same service instance context, which may come from different clients (service agents) or the same client. The nature of WCF concurrency can be illustrated by figure 1.

Figure 1 Processing of multiple concurrent requests through a InstanceContext

Because the concurrent processing of WCF belongs to the behavior of the service itself, we control the concurrent policies taken in the form of service Behavior, and the different concurrency policies are defined under the corresponding concurrency mode (concurrency mode).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.