Orleans and Orleans

Source: Internet
Author: User

Orleans and Orleans
Introduction

This essay mainly records the course and understanding of Orleans, which will be updated throughout the learning process. The ideas and understanding may be somewhat biased. If you are lucky enough to see this article, I hope to give criticism and correction.

Navigation

(1) Getting Started example

2.

3.

Understanding

First, Microsoft Orleans builds a high-concurrency, distributed large-scale application framework in. net in a simple way.

Official documentation and source code: http://dotnet.github.io/orleans/

The following is an introduction to Microsoft Orleans Getting Started Guide (https://www.cnblogs.com/endv/p/6147976.html)

The Orleans framework can be used to build large-scale, highly concurrent, and distributed applications without learning professional distributed and concurrency knowledge frameworks. It is designed and applied to cloud computing by Microsoft. It is widely used in Microsoft cloud products, and the cloud services of the official Microsoft games Halo4 and Halo5 (halo | halo) are all carried by it, and many companies are using it.

Features:

1. The default scalability allows you to easily expand your applications to hundreds of services by building complex distributed applications.

2. Low latency, which saves your program status in memory, so your application can quickly respond to requests.

3. Simplified concurrency. Orleans allows you to use C # code to construct Asynchronous Message Processing between Actors.

Note: The Actor model is a conceptual model used to process concurrent computing. It defines a series of general rules for system components to act and interact. An Actor refers to the most basic computing unit. It can receive a message and perform computation based on it. I have not gone deep into the details. Please refer to http://www.jianshu.com/p/449850aa8e82)

In Orleans, actors are called grains and are represented by an interface. Actors messages are accepted asynchronously as follows:

public interface IMyGrain : IGrainWithStringKey{    Task<string> SayHello(string name);}

Implementation code running in the Orleans framework
public class MyGrain : IMyGrain{    public async Task<string> SayHello(string name)    {        return "Hello " + name;    }}

Create a proxy object and call the Grains method to send messages.
var grain = GrainClient.GrainFactory.GetGrain<IMyGrain>("grain1");await grain.SayHello("World");

  Cluster:

A large number of silos work together to form an orleans cluster. orleans runs fully automated cluster management.

All silo use a dynamically updated shared Member repository, which helps to coordinate cluster management. By reading the shared repository, you can learn about the location of the other member. At any time, A silo can be registered in shared storage to connect to a cluster.

Clusters in this way can be dynamically expanded at runtime. Orleans provides elasticity and availability to delete invalid silos from the cluster.

Orleans and client code

Orleans includes two different parts: Orleans basic part (grains) and client part

Part of Orleans is composed of the application runtime service silos grains, the Grain Code executed during runtime under scheduling restrictions, and the internal Orleans programming model.

The client is usually a web Front-end. A small number of Orleans client libraries are used to connect to the Orleans part, so that the client code can communicate by referencing a grain reference of the server.

For example, an ASP. NET web application is running on the server and can be an Orleans client. The client runs in the main thread of the. net application pool, and is not subject to scheduling restrictions and Orleans runtime guarantee.

  Orleans imported package

Orleans has two required packages: Microsoft. Orleans. Server (Server package) and Microsoft. Orleans. Client (Client package)

You can directly install it in NuGet. It will automatically install other dependent packages. vs is so worry-free, but note that, do not update the versions of other packages referenced by the Orleans package at will, which may lead to some strange errors (blood lessons)

  What components does Orleans have?

I simply divided Orleans into four parts.

IGrains: All Grains class interfaces to be extended are placed here.

Grains: implements all the interfaces specified by IGrain and all Grain classes, including their methods and fields.

Host: In this example, we want to run Silo. That is, the server

Client: In this example, you need to run GrainClient. It needs to communicate with the Host, which is the client.

 

Related Article

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.