A step-by-step familiarity with akka.net (i)

Source: Internet
Author: User
Tags message queue

A step-by-step familiarity with akka.net (i)

tags (space delimited):. Netcore distributed

I. Unfavorable flag

?? Long time no article, opened the previous years to write the blog, see there are two targets "code generator" and "File stealth." It is not too difficult to say that the dystocia has not come out yet. There are also pre-determined learning plans-Learn spring boot first, then familiar with spring cloud, and then go to the. NET environment to find a better solution. However, after the spring boot, for some reason, the cloud has not continued to become familiar.
?? So, there is plenty of time and momentum to achieve execution, and then target it.

Second, parallel operation

?? In recent days, there was a working scene in which some tables of a system were synchronized to the B system. Because of the integration of data, the old version of the write is a step-by-minute paging query, and then call the B system Integration data Interface integration data, the entire synchronization speed is quite slow. Later changed to paging query data first dropped to the message queue, and then open a few consumer side to parallel processing, the speed doubled dozens of times times or even hundreds. Of course, the B system also optimizes the removal of some queries, putting forward queries before the message queue, which can increase the consumption speed.
?? As a person of pursuit, such a result is very happy. Of course, if the batch-type query, batch-type data processing, batch-type submission database operation, the speed will be more than hundreds of thousands of times or more than thousand, but the time is limited, part is too wide, the current processing speed and business capacity to cope with, optimization ends, thinking but will not stop.

Third, future-oriented thinking

?? As explained here, A is a business system, B is a marketing system. A system of any update will be notified to B system, B system aggregation data, and then make marketing action, so B system action processing time is longer than the update data of a system, if a system has a large number of imports or frequent updates, B system is difficult to dispose of in a short time. So the thinking direction is: A system to accumulate a batch of updates such as a minute, and then by the message queue Notification B system, B system batch processing these notifications.

* Old version

A系统->B系统: A单条数据的任何修改通知B

* Thinking version

A系统->B系统: A单条数据的修改积累到一批再通知B

The above ideas, rely on httpruntime or redis can be achieved. But it seems that it is not very good to consider the issue of locking.
?? The above nonsense is so much to tell a point of problem. With this point, in the process of familiar with the distributed framework, there is reference to match the value, not too confused.

To understand the next akka.net.

?? Akka.net is a scalable, resilient system designed to span processor cores and networks, allowing you to focus on meeting business needs rather than writing low-level code to provide reliable behavior, fault tolerance, and high performance. Akka.net uses the Actor model to provide an abstraction level, making it easier to write the right concurrency, parallel, and distributed systems. The actor model spans the collection of akka.net libraries, giving you a consistent way to understand and use them.

What is an Actor model

The actor's basic feature is that they model the world as stateful entities that communicate with each other through explicit message delivery.
As a computational entity, the actor has these characteristics:

They use asynchronous message passing to replace method calls
They can manage their own state.
* When replying to a message, they can:
?? > Create other actors
?? > Send a message to other actors
?? > Stop actors or their own.

Attention
Since akka.net enforces parental oversight, each actor is supervised and (possibly) a supervisor of his or her child, so it is advisable to familiarize yourself with the actor system and supervision and supervision, and also to help read the actor's reference, path and address.

For more detailed documentation, please go to the official website.
The following begins the code of the masturbate .

Sample code
*vs new Console Project *nuget installation Akka
?? * Code (too troublesome, all put in a file)
Using akka.actor;using System;namespace demoakka.simple{class Program {static void Main (string[] args)            {var system = Actorsystem.create ("Mysystem"); var greeter = System.            Actorof<greeactor> ("Student"); while (true) {var i = Math.Abs (Guid.NewGuid ().                GetHashCode ()); Greeter.                Tell (new Greemessage () {MsgId = i, Realname = $ "Real{i}"                });                var key = Console.ReadLine ();                if (key = = "Exit") {break;    }}}///<summary>//Actor, can receive message processing. </summary> public class Greeactor:receiveactor {public Greeactor () {RECEIVE&L T Greemessage> (greet = {Console.WriteLine ($ "{DateTime.Now}---msgid:{greet. Msgid},realname:{greet.            Realname} "); });       }}///<summary>//The entity used to deliver the message.        </summary> public class Greemessage {public long MsgId {get; set;}    public string Realname {get; set;} }}
* Run effect (input various characters, message to actor)

?? What can I do with the above code? As far as I can see, decoupling is easy to expand. Of course, is also a feature of the Actor model, message delivery to replace the method call.

?? In my expectation, I should first take a akka.net part of the theoretical explanation, and then explain the implementation of the code part of the principle. But I think too far, the actual time is too late. Step by step.

A step-by-step familiarity with akka.net (i)

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.