The basic principle of the concept of high-performance framework Ray's final consistency

A, Actor Introduction

Actor is a concurrency model is an alternative to shared memory concurrency model.

Shortcoming shared memory model:
  1. Shared memory model using a variety of locks to solve the state competition, poor performance and make coding is complicated and prone to error.

  2. Shared memory is limited to a single node server resource limitations.

Actor model advantages:
  1. To communicate messages between threads, message sequence single thread, there is no competition status.

  2. Way to communicate a message, you can easily set up a cluster.

  3. The State and Behavior bindings, better control of the state.

Glossary:

Mailbox: can be understood as first in first out queue, and the cache is responsible for receiving messages delivered.

State: state information, such as the user's account balance information.

Behavior: responsible for order processing Mailbox messages, such as debit messages, arrival messages, check your balance messages.

Two, Orleans Introduction

Actor .Net Orleans is a foundation to maintain cross-platform open-source framework, Virtual Actor original concept, support for distributed clusters.

Project Address: http://dotnet.github.io/orleans/

It has the following advantages:
  1. Access to objects Actor, consistent with object-oriented habits.

  2. Proposed the concept of the Virtual Actor, fine-grained access ID by Actor, Actor can carry tens of millions of objects.

  3. The Stateful support, buffer layer can replace more precise control of the memory state, reducing the pressure on the database.

  4. High-performance, single Actor can support 100,000 + in QPS.

  5. Activation transparent, Actor of visitors is permanent, but also provide complete life cycle control, easy to expand.

  6. Native support for clusters, but Actor location transparency, visitors do not need to concern Actor running load will be scheduled according to the node where the node cluster.

  7. Offers a variety of support cluster, the cluster is very easy to deploy, support AdoNet, Zookeeper, K8s, SF and so on.

  8. It provides a complete solution for unit testing, unit testing easy.

  9. It provides a perfect monitoring tool that detailed monitoring indicators.

  10. Based on .net core, supports a variety of platforms.

Glossary:

Silo: a node in the cluster, Grains responsible for maintaining the current node.

SiloGateway: Each node exists, is responsible for maintaining the cluster status and forwards the request.

Grain: equivalent Actor, identified by ID + Interface.

Client: Grain used to access the cluster of client tools.

Three, Ray introduced

Ray Actor model constructed based on event-based distributed ultimately traceable high performance consistency frame, the traditional split complicated distributed transaction processing flow by way of the linear event-driven, performance and higher throughput, more responsive.

Ray offers state maintenance, event publish / subscribe, such as power control, distributed transactions and other modules, and built a distributed ID, distributed lock, lock the weight distributed services.

Ray provide superior performance, can achieve a single Actor 20000 / s events.

Project Address: https://github.com/RayTale/Ray

Glossary:

  1. State (State): aggregate data memory.

  2. Event (Event): change of status information.

  3. EventBus: providing events and send event consumer subscriptions.

  4. Idempotence: to ensure event delivery times will not cause an abnormal state, such as transfer event A chart on multiple service B, but B will only increase once the balance.

Ray's final consistency principle transfer

A user calls A method of transferring accounts Actor of transfer funds, check balances carried Actor account A state based on memory, if the balance is insufficient, the direct cause of the failure is returned, if the check is to produce a successful transfer Event (recording target account Id, transfer amount , the remaining balance) and persisted, and then transmitted to modify memory state EventBus. EventBus a subscriber balance reading event information repository A modified account transfers and bill inserted into the bill a table, call another subscriber account Actor arrival method B according to event information based on, will produce a B account Actor arrival Event (arrival record amount, FromId, the remaining balance) and persisted, and then transmitted to modify memory state EventBus, EventBus arrival of a subscriber billing according to the balance of the read event information modification repository and inserted into the B accounts in a billing table .

Guess you like

Origin www.cnblogs.com/gengzhe/p/ray_actor.html