带有 Actor 的设计模式 [英] Design Patterns with Actors

查看:33
本文介绍了带有 Actor 的设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于演员的范式非常酷.它的有效扩展能力使其成为必须评估任何并发系统的范例.我已经阅读了一些关于它的内容,并且对核心意图有一个不错的想法:用消息和多个参与者"驱动昂贵的操作,以最大限度地减少由于请求/响应交互而导致的等待,从而增加系统的吞吐量.但是,我还没有充分了解人们与演员一起使用的设计模式.我正在寻找基于角色的系统的设计模式.

The actor based paradigm is pretty cool. Its ability to scale effectively makes it a paradigm to must-evaluate for any concurrent system. I have done some reading about it, and have a decent idea about the core intent: drive your expensive operation with messages and multiple "actors" to minimize waits due to request/response interactions thereby increasing the throughput of your system. However, I have not had sufficient exposure to the design patterns people use with actors. I am looking for design patterns for actor based systems.

actor 设计模式的一个常见示例是一个系统,其中有一个主协调者 actor 和一群子工作者 actor.他们掌握将昂贵的操作映射到较小的块,将较小的块作为消息发送给一群工人,等待他们的响应,然后将它们全部缩减为结果.在这种模式的一些复杂示例中,worker actor 通知 master 他们已准备好进行更多工作,并且 master 根据需要将更多工作路由给他们.这确保了工作的适当平衡,并且在工作规模变化很大时非常有用.

A common example of an actor design pattern is a system where there is a master-coordinator actor and a bunch of child worker actors. They master maps the expensive operation to smaller chunks, sends the smaller chunks as messages to the bunch of workers, waits for responses from them and then reduces them all to the result. In some sophisticated examples of this pattern , the worker actors notify the master that they are ready for more work, and the master routes to them more work on demand. This ensures proper balance of work and is useful when job sizes vary quite a bit.

我四处搜索有关更多基于 actor 的模式的文献,但除了上述示例之外,还找不到任何其他示例.我还没有浏览 Akka Actors 项目示例,但任何指针都会非常有用.

I searched around for literature on more actor based patterns and couldn't find any examples other than the one above yet. I am yet to go through Akka Actors project samples, but any pointers would be very useful.

推荐答案

我强烈推荐 Derek Wyatt 的 "Akka并发"一书——它侧重于最新的 Akka 发行版 (2.1),并介绍了使用 Akka 和许多设计模式(强调事件驱动设计)的几个最佳实践.但是,它确实假设您对 Scala 有一定的了解.

I highly recommend Derek Wyatt's "Akka Concurrency" book - it is focused on the latest Akka distribution (2.1) and goes over several best practices of using Akka and lots of design patterns (emphasizing event-driven design). It does assume a fair bit of knowledge in Scala however.

来自 Akka 的帖子博客之夏 系列也很有帮助(其中一些也是 Derek [和我] 写的).

The posts from the Akka Summer of Blog series is also really helpful (several of them are also written by Derek [and one by me]).

这篇关于带有 Actor 的设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆