Node.js的事件系统与Akka的actor模式不同? [英] How is Node.js evented system different than the actor pattern of Akka?

查看:207
本文介绍了Node.js的事件系统与Akka的actor模式不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经与 Node.js 一起工作,并认为自己对Java很好。但是我刚刚发现了 Akka ,并立即对其演员模式感兴趣(从我的理解)。



现在,假设我的JavaScript技能与我的Scala / Java技能相当,我想要关注两个系统的实用性。特别是在Web服务方面。



我的理解是,Node处理许多并发操作非常出色。我想像一个资产管理系统的Node Web服务可以很好地处理许多用户同时提交变更(在一个庞大的流量应用程序中)。



但是在阅读关于Akka的演员之后,它接缝将会在同一件事情上表现出色。而且我喜欢把工作减少到大块的想法。另外,几年以前,我在Erlang中捣蛋,爱上了它使用的信息传递系统。



我在处理复杂业务逻辑的许多应用程序上工作,认为是时候重新加入一个或另一个。特别是升级旧版Struts和C#应用程序。



无论如何,避免圣战,两个系统有什么根本不同?似乎都是朝着同一个目标迈进。有可能Akka的自我修复建筑具有优势。



编辑



解决方案

细节(在Node.js的情况下,我知道的太少),主要的区别在于,它不支持并行性,而只支持并发性,而Akka支持这两者。两个系统都是完全事件驱动的,可以扩展到大的工作负载,但是缺乏并行性使得Node.js变得很困难(即并行性通过启动多个节点并相应地调度请求进行显式编码;因此在运行时是不灵活的) ,而由于其可调整的多线程执行程序,Akka非常容易。鉴于小型单独的工作单位(演员调用),Akka将自动并行执行您的工作。



另一个重要的不同之处在于Akka包括以结构化方式处理故障的系统(通过使每个actor由其父级监督,这是强制性的),而Node.js依赖于作者的约定将错误条件从回调传递给回调。基本的问题是异步系统不能使用基于同步堆栈的系统采用的异常的标准方法,因为在回调错误发生时,调用代码将转移到不同的任务。系统内置的故障处理使得在该系统上构建的应用程序更有可能是稳健的。



以上并不是详尽无遗,我相信有更多的差异。


I've worked with Node.js for a little while and consider myself pretty good with Java. But I just discovered Akka and was immediately interested in its actor pattern (from what I understand).

Now, assuming my JavaScript skills were on par with my Scala/Java skills, I want to focus on the practicality of either system. Especially in the terms of web services.

It was my understanding that Node is excellent at handling many concurrent operations. I imagine a good Node web service for an asset management system would excel at handling many users submitting changes at the same time (in a large, heavy traffic application).

But after reading about the actors in Akka, it seams it would excel at the same thing. And I like the idea of reducing work to bite-sized pieces. Plus, years ago I dabbled in Erlang and fell in love with the message passing system it uses.

I work on many applications that deal with complex business logic and I'm thinking it's time to jump heavier into one or the other. Especially upgrading legacy Struts and C# applications.

Anyway, avoiding holy wars, how are the two systems fundamentally different? It seems both are geared towards the same goal. With maybe Akka's "self-healing" architecture having an advantage.

EDIT

It looks like I am getting close votes. Please don't take this question as a "which is better, node or akka?". What I am looking for is the fundamental differences in event driven libraries like Node and actor based ones like Akka.

解决方案

Without going into the details (about which I know too little in the case of Node.js), the main difference is that Node.js supports only concurrency without parallelism while Akka supports both. Both systems are completely event-driven and can scale to large work-loads, but the lack of parallelism makes it difficult in Node.js (i.e. parallelism is explicitly coded by starting multiple nodes and dispatching requests accordingly; it is therefore inflexible at runtime), while it is quite easy in Akka due to its tunable multi-threaded executors. Given small isolated units of work (actor invocations) Akka will automatically parallelize execution for you.

Another difference of importance is that Akka includes a system for handling failure in a structured way (by having each actor supervised by its parent, which is mandatory) whereas Node.js relies upon conventions for authors to pass error conditions from callback to callback. The underlying problem is that asynchronous systems cannot use the standard approach of exceptions employed by synchronous stack-based systems, because the "calling" code will have moved on to different tasks by the time the callback’s error occurs. Having fault handling built into the system makes it more likely that applications built on that system are robust.

The above is not meant to be exhaustive, I’m sure there are a lot more differences.

这篇关于Node.js的事件系统与Akka的actor模式不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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