actor

Does it make sense to use a pool of Actors?

爱⌒轻易说出口 提交于 2019-12-05 03:02:34
I'm just learning, and really liking, the Actor pattern. I'm using Scala right now, but I'm interested in the architectural style in general, as it's used in Scala, Erlang, Groovy, etc. The case I'm thinking of is where I need to do things concurrently, such as, let's say "run a job". With threading, I would create a thread pool and a blocking queue, and have each thread poll the blocking queue, and process jobs as they came in and out of the queue. With actors, what's the best way to handle this? Does it make sense to create a pool of actors, and somehow send messages to them containing or

How can I identify a remote actor?

送分小仙女□ 提交于 2019-12-05 02:01:37
问题 I have a remote actor (client) which is registering with another remote actor (server) and then later deregistering (with a shutdown hook). However, although the server picks up the de-registration, the actual sender property is a different Channel object ; so in my server logs I have: Registered new client [scala.actors.Channel@158e282]; supporting 1 clients De-registered client [scala.actors.Channel@1caf0b6]; supporting 1 clients How can I determine (on the server side) that this was the

How to limit concurrency when using actors in Scala?

帅比萌擦擦* 提交于 2019-12-05 00:48:55
I'm coming from Java, where I'd submit Runnable s to an ExecutorService backed by a thread pool. It's very clear in Java how to set limits to the size of the thread pool. I'm interested in using Scala actors, but I'm unclear on how to limit concurrency. Let's just say, hypothetically, that I'm creating a web service which accepts "jobs". A job is submitted with POST requests, and I want my service to enqueue the job then immediately return 202 Accepted — i.e. the jobs are handled asynchronously. If I'm using actors to process the jobs in the queue, how can I limit the number of simultaneous

Scala Actors: if react never returns, why does it need to be in a loop{}, and why doesn't while(true) work?

我的未来我决定 提交于 2019-12-05 00:01:22
Just getting started on Scala Actors. The Scala website says: Thread-blocking operations can be avoided by using react to wait for new messages (the event-based pendant of receive ). However, there is a (usually small) price to pay: react never returns. ... Note that using react inside a while loop does not work! However, since loops are common there is special library support for it in form of a loop function. It can be used like this: loop { react { case A => ... case B => ... } } I'm now confused - there seems to be a contradiction: a) If react never returns, then what's the point of

Akka Actor Props factory

随声附和 提交于 2019-12-05 00:01:05
问题 Akka and I are getting to know each other. From : Akka 2.3.6 (current) Actor Recommended Practice These is an example actor called DemoActor : class DemoActor(magicNumber: Int) extends Actor { def receive = { case x: Int => sender() ! (x + magicNumber) } } In Recommended Practices section of the doc it states : "It is a good idea to provide factory methods on the companion object of each Actor which help keeping the creation of suitable Props as close to the actor definition as possible."

高系统的分布性有状态的中间层Actor模型

假如想象 提交于 2019-12-04 23:23:34
写在前面 https://www.cnblogs.com/gengzhe/p/ray_actor.html Orleans是基于Actor模型思想的.NET领域的框架,它提供了一种直接而简单的方法来构建分布式大规模计算应用程序,而无需学习和应用复杂的并发或其他扩展模式。我在2015年下半年开始应用Orleans,当时公司的交易系统采用的架构就是基于Orleans框架的,其展现出来的高性能、高并发以及惊人的稳定性深深地吸引了我,也让我认识到了传统三层无状态架构的缺陷。本文主要关注Orleans的思想基础,Actor模型及其应用。 Orleans思想基础:Actor模型 传统三层无状态架构的缺陷 在讨论Actor模型之前,我们可以先讨论一下传统三层架构在当前高并发环境中所面临的尴尬境遇。 三层架构包括表示层、业务逻辑层或者叫做中间层、数据访问层(也就是存储层),其架构图如下所示: 正如我们在实践中所知道的那样,中间层和数据访问层在伸缩性方面有着很大的限制,同时存储层常常会成为系统的瓶颈,这就意味着整套系统也会因为存储层的限制而变得低效。通常的做法是在中间层与存储层中间加一层缓存逻辑出来,以提升系统性能,但是很快就会遇到存储层与缓存层的数据一致性问题,这无疑为开发人员和运维人员增加了额外的工作量。 试想一下,如果我们中间层本身就携带着状态或者简单来说中间层与缓存层是合二为一的

Can I customize azure service fabric vm nodes?

谁都会走 提交于 2019-12-04 22:26:59
问题 I would like to leverage reliable actor model in the azure service fabric. Our actor model computation requires specific software installed on the vm node. Can I have custom software installed (on top of the azure service fabric software) in the vm nodes so that I can leverage this software in the actor model computation? As part of the my actor model deployment into azure service fabric, can I author this custom software installation into it? Is this how it should be done? Or are there any

高性能最终一致性框架Ray之基本概念原理

前提是你 提交于 2019-12-04 21:02:22
高性能最终一致性框架Ray之基本概念原理 一、Actor介绍 Actor是一种并发模型,是共享内存并发模型的替代方案。 共享内存模型的缺点: 共享内存模型使用各种各样的锁来解决状态竞争问题,性能低下且让编码变得复杂和容易出错。 共享内存受限于单节点的服务器资源限制。 Actor模型的优点: 线程之间以消息进行通信,消息按顺序单线程处理,不存在状态竞争。 以消息方式通信,可以方便的组建集群。 把State和Behavior绑定,能更好的控制状态。 名词解释: Mailbox:可以理解为先入先出队列,负责接收和缓存送达的消息。 State:状态信息,比如用户的账户余额信息。 Behavior:负责按顺序处理Mailbox中的消息,比如扣款消息、到账消息,查询余额消息等。 二、Orleans介绍 Orleans是.Net基金会维护的一个Actor跨平台开源框架,独创Virtual Actor概念,支持分布式集群。 项目地址: http://dotnet.github.io/orleans/ 有以下优点: 以对象方式访问Actor,符合面向对象的使用习惯。 提出Virtual Actor概念,可以通过ID访问细粒度的Actor,能承载数千万的Actor对象。 支持Stateful,能替代缓存层来对内存状态进行更精确的控制,减少数据库的压力。 高性能,单个Actor能支持10万+的QPS。

Akka Actor - wait for some time to expect a message, otherwise send a message out

戏子无情 提交于 2019-12-04 20:35:13
问题 Is it possible to make an Actor wait for X amount of seconds to receive any message, and if a message is received, process it as usual, otherwise send a message to some other Actor (pre-determined in the constructor)? 回答1: Yes, if you want to wait for any message, you simply set a receiveTimeout : http://doc.akka.io/docs/akka/current/scala/actors.html#receive-timeout (The docs is slightly misleading here, you can set the receiveTimeout after every message also) 回答2: It's possible, have a look

RemoteActor.select - result deterministic?

a 夏天 提交于 2019-12-04 19:56:49
I wonder if there is any determinism when calling val delegate = RemoteActor.select(). I'm asking this, because I noticed that the program doesn't terminate, when I'm sending delegates over the net. Are there any other side effects, which depend on the delegate? Are there any rules, when RemoteActor.select will return the same delegate for the same arguments? Here's some example code which demonstrates the RemoteActor.select problem: package test import scala.actors.Actor, Actor._ import scala.actors.remote._, RemoteActor._ object DelegateTest { def main(args :Array[String]) { val actor = new