scala 构建基于 Actor 的系统的设计模式/最佳实践

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3931994/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 02:30:12  来源:igfitidea点击:

Design patterns/best practice for building Actor-based system

scalaerlangactor

提问by Vasil Remeniuk

I am struggling to find any decent links to design patterns, best practice or good, basic architectural principles that should be used in building Actor-based apps. Those few that I know of are:

我正在努力寻找设计模式、最佳实践或良好的基本架构原则的任何体面链接,这些链接应该用于构建基于 Actor 的应用程序。我所知道的几个是:

Blog posts, articles, WIKIs, guides

博客文章、文章、WIKI、指南

Papers

文件

Books

图书

Implementations

实现

  • Akka Framework(alternative implementation of actors in Scala with a port of several Erlang behaviors and lots of other relized patterns for actors)
  • Scalaz Actors(actor compositions, strategies and promises)
  • Akka 框架(Scala 中演员的替代实现,带有几个 Erlang 行为的端口和许多其他演员的相关模式)
  • Scalaz Actors(演员作品、策略和承诺)

Presentations

演示文稿

Examples from highscalability.com

来自 highscalability.com 的示例

  • Simple queuing service (SQS)- this service provides an internet scale queuing service for storing messages. Distributed actors put work on the queue and take work off the queue. Typical use: a centralized work queue. You put jobs on the queue and different actors can pop work of the queue and process them when they get CPU time. Part of scalability. Have any number of producers and consumers. You don't worry about it. Queues are spread across multiple machines and multiple data centers.
  • 简单排队服务 (SQS)- 此服务提供用于存储消息的 Internet 规模排队服务。分布式参与者将工作放入队列并从队列中取出工作。典型用途:集中式工作队列。您将作业放在队列中,不同的参与者可以弹出队列中的工作并在获得 CPU 时间时处理它们。可扩展性的一部分。有任意数量的生产者和消费者。你不用担心。队列分布在多台机器和多个数据中心。

采纳答案by oxbow_lakes

This is related to a previous question, if not exactlythe same!

这与之前的问题有关,如果不完全相同

It's not such a simple question because the actor modelof concurrency allows for many different types of applications to be built, from a stateful single-VM application (with a few separate actor classes) to a stateless cluster of thousands of instances of an actor class.

这不是一个简单的问题,因为并发的actor模型允许构建许多不同类型的应用程序,从有状态的单VM应用程序(具有几个单独的actor类)到一个actor类的数千个实例的无状态集群.

The core principles are the same however:

然而,核心原则是相同的:

  • Never expose an actor's state
  • Communicate solely via the passing of immutable messages
  • 永远不要暴露演员的状态
  • 仅通过传递不可变消息进行通信

回答by jamie

I posted a blog on learnings of actor developmentin Scala a few weeks ago. It's a post of a best practices and things to avoid based on a few years of experience with the paradigm.

几周前,我发布了一篇关于在 Scala 中学习演员开发的博客。这是一篇基于几年范式经验的最佳实践和要避免的事情的帖子。

回答by botkop

The book 'Reactive Design Patterns' is in the making at Manning.

Manning 正在编写“Reactive Design Patterns”一书。

See: https://www.manning.com/books/reactive-design-patterns

请参阅:https: //www.manning.com/books/reactive-design-patterns