除了可扩展性之外,使用 Node.js 的架构原因还有哪些?

发布于 2024-10-14 02:55:56 字数 266 浏览 4 评论 0原文

我读到的关于为什么使用 Node.js 的最常见主题是由于它的事件化、非阻塞 I/O 模型而获得高可扩展性。我试图了解其他非可扩展性用例(除了用作通用服务器端 JavaScript 引擎之外)。

  1. 如果我不关心可扩展性,node.js 是否还有其他用例?
  2. 如果#1 是,它们是什么?
  3. Node.js 的使用是否适合任何特定类型的应用程序架构?例如,类似于某些键/值(nosql - 呃,我讨厌这个词)数据库除了出于可扩展性原因之外的有用性。

The most common theme I read about why to use node.js is for high scalability due to it's evented, non-blocking I/O model. I'm trying to understand other non-scalability uses cases (and aside from being used as a general server-side javascript engine).

  1. Does node.js have other use cases if scalability isn't a concern of mine?
  2. If yes to #1, what are they?
  3. Is node.js usage appropriate for any particular type of application architectures? E.g. similar to how some key/value (nosql - ugh I hate that term) databases are useful other than for scalability reasons.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

简单气质女生网名 2024-10-21 02:55:56

我尝试使用 Node 的原因是,在服务器和客户端之间发送 JSON 数据以进行 ajax 请求非常容易。
如果您使用像 MongoDB 这样的东西,它也将数据存储为 JSON 对象,那么您永远不必担心翻译或解析数据。

如果您的网站使用大量 ajax,并且您将数据作为 JSON 对象(而不是 XML 或纯文本)发送,那么 node.js 将为您节省大量精力。

My reason for trying out node is the fact that it is incredibly easy to send JSON data between the server and the client for ajax requests.
If you use something like MongoDB, which stores data as JSON object too, you never have to worry about translating or parsing your data.

If your site uses a lot of ajax, and you're sending your data as JSON objects (rather than XML or plain text) then node.js will save you a fair bit of effort.

樱桃奶球 2024-10-21 02:55:56

我认为这篇博客文章总结得很好:
http://debuggable.com/posts/understanding-node -js:4bd98440-45e4-4a9a-8ef7-0f7ecbdd56cb

简而言之(pro node.js):

  • 加快
  • Javascript(尤其是如果您已经知道的话)
  • node.js 的效率

真的很棒。尝试一下! :)

I think this blog posts sums it up quite well:
http://debuggable.com/posts/understanding-node-js:4bd98440-45e4-4a9a-8ef7-0f7ecbdd56cb

In short (pro node.js):

  • Speed
  • Javascript (especially if you know it already)
  • Efficiency

node.js is really great. Give it a try! :)

浪菊怪哟 2024-10-21 02:55:56

我能想到一个原因,但不是很深。基本上,如果您正在开发 RIA,您的整个堆栈都可以是 javascript。这可能有一定的价值。

但我会质疑我自己的答案,即想法是,即使它使客户端开发人员更容易访问服务器端代码,他们仍然需要了解他们的服务器堆栈是如何工作的。所以还是有一些学习的地方。

I can think of one reason, but its not very deep. Basically, If you are developing an RIA, your entire stack can be javascript. That might have some value.

But Ill question my own answer, namely the thought is, even if it makes the server side code more accessible to client side developers, they still need to understand how their server stack works. So there is still some learning to.

雾里花 2024-10-21 02:55:56

准确地说,我认为您问题中的通用服务器端 JavaScript 引擎是 V8,而根据其创建者的说法,Node 是为“编写网络程序脚本”而构建的。

根据他的许多评论,我认为他不像我们许多人那样广泛地看待它,但他认识到它的发展方向。 [我不能代表任何人——这只是我根据我所见过的著作和演示文稿做出的解释。]

因此,它从较低的层次来处理问题,使 HTTP 成为一等公民,并且恰好是真正的很酷,我认为这足以成为我们大多数人的“用例”。 ;)

它确实有一个学习曲线,并且由于其快速发展,并不是最稳定的构建平台。我相信时间会证明它在哪里最有用。

目前,由于其轻量级、异步特性以及一般的 Web 开发,人们将其用于“实时”应用程序,尽管在我看来,它的最佳位置仍然是其最初声明的目的。

To be accurate, I think the general server-side JavaScript engine in your question would be V8, while according to its creator Node was built for "scripting network programs."

Based on many of his comments I don't believe he views it as broadly as many of us do, but recognizes where it can go. [I can't speak for anyone else--that's just my interpretation based on the writings and presentations I've seen.]

So it approaches things from a somewhat lower level, makes HTTP a first-class citizen and just happens to be really cool, which I think makes it enough of a "use case" for most of us. ;)

It does have a learning curve and isn't the most stable platform to build on due to its rapid development. I believe time will tell where it's most useful.

For now people are using it for "real-time" apps due to its lightweight, asynchronous nature, as well as general Web development, though IMO its sweet spot remains with its originally stated purpose.

天涯沦落人 2024-10-21 02:55:56

除了非阻塞 I/O 模型、可扩展性和所有“主要原因”之外,我喜欢 Node.js 的地方是:

  • 它的框架的轻量级性质。基础知识很容易学习。
  • 开发者社区在 github 上构建了大量有用的模块和库,这些模块和库正在扩展 Node.js 轻量级核心及其功能。
  • 构建服务器端和实时系统(例如基于 http 或套接字)非常简单快捷,无需了解复杂的库。

What I like about node.js aside from non-blocking I/O model, scalability and all that "primary reasons" stuff:

  • Lightweight nature of it's framework. Basics are easy to learn.
  • Developer community building tons of useful modules and libraries on github which are expanding node.js lightweight core and it's capabilities.
  • It's really easy and fast to build server side and real-time systems (for example http or socket based) without the knowledge of complex libraries.
肤浅与狂妄 2024-10-21 02:55:56

我喜欢使用 NodeJS 来编写测试工具,因为你可以非常快速地编写存根/服务器/客户端。您可以轻松地驱动您的应用程序。我可以轻松编写第三方后端服务器脚本来对我的应用程序进行性能测试。我还用它来驱动我的应用程序。我可以使用 setTimout 执行复杂的客户端服务器场景,以根据我想要的任何逻辑触发多个事件,并大规模测试它们。

I like to use NodeJS to write testing harness because you can write a stub/server/client really quickly. And you can drive your application, with ease. I can easily script a third party back-end server to do performance testing on my application. I also use it to drive my application. I can perform complex client server scenarios using setTimout to cause multiple events to be trigger based on any logic I want and test them at scale.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文