简体   繁体   English

heroku爱好dyno上的node.js,局限性

[英]node.js on heroku hobby dyno, limitations

I am having trouble grasping the performance limitations of using node with a Heroku Hobby dyno, a type which contains just 1 web worker. 我无法掌握将节点与Heroku Hobby dyno一起使用时的性能限制,该类型仅包含1个Web worker。

My heroku server is used to respond to post requests and initiate server to server communication. 我的heroku服务器用于响应发布请求并启动服务器到服务器的通信。 We will call this 'the process'. 我们将其称为“过程”。

Node.js is javascript and has only one event loop, does this mean that if my heroku server is not already done the with the process, that it will be unable to initiate another one? Node.js是javascript,只有一个事件循环,是否表示如果myheroku服务器尚未完成该过程,它将无法启动另一个事件循环?

Client side, a user sends one post request, which launches 'the process'. 在客户端,用户发送一个发布请求,该请求启动“流程”。

If the process is not complete, can a second user send another post request and expect anything to happen? 如果过程未完成,第二个用户是否可以发送另一个发帖请求并期望发生任何事情? Will my server hang until the first process is done? 我的服务器是否会挂起,直到完成第一个过程?

In my preliminary testing it almost seems like it has no problems with two users sending nearly simultaneous requests, so I'm not sure what limitation I would hit 在我的初步测试中,两个用户几乎同时发送请求似乎没有问题,所以我不确定我会遇到什么限制

This is not an issue according to Heroku's docs, you'll be able to handle multiple requests without a problem with Node.js. 根据Heroku的文档,这不是问题,您将能够处理多个请求而Node.js不会出现问题。

Dynos and requests 测功机和要求

A single dyno can serve thousands of requests per second, but performance depends greatly on the language and framework you use. 单个dyno每秒可以处理数千个请求,但是性能很大程度上取决于您使用的语言和框架。

A single-threaded, non-concurrent web framework (like Rails 3 in its default configuration) can process one request at a time. 单线程,非并发Web框架(如其默认配置中的Rails 3)可以一次处理一个请求。 For an app that takes 100ms on average to process each request, this translates to about 10 requests per second per dyno, which is not optimal. 对于平均需要100毫秒处理每个请求的应用程序,这意味着每个dyno每秒大约10个请求,这不是最佳选择。

Single threaded backends are not recommended for production applications because of their inefficient handling of concurrent requests. 不建议将单线程后端用于生产应用程序,因为它们对并发请求的处理效率低下。 Choose a concurrent backend whenever developing and running a production service. 开发和运行生产服务时,请选择并发后端。

Multi-threaded or event-driven environments like Java, Unicorn, EventMachine, and Node.js can handle many concurrent requests. Java,Unicorn,EventMachine和Node.js等多线程或事件驱动的环境可以处理许多并发请求。 Load testing your app is the only realistic way to determine request throughput. 对应用程序进行负载测试是确定请求吞吐量的唯一现实方法。

Further reading: 进一步阅读:

On dynos: https://devcenter.heroku.com/articles/dynos#dyno-types 在dynos上: https ://devcenter.heroku.com/articles/dynos#dyno-types

On jobs and queueing: https://devcenter.heroku.com/articles/background-jobs-queueing 关于作业和排队: https : //devcenter.heroku.com/articles/background-jobs-queueing

Async Workers: https://devcenter.heroku.com/articles/asynchronous-web-worker-model-using-rabbitmq-in-node 异步工作者: https : //devcenter.heroku.com/articles/asynchronous-web-worker-model-using-rabbitmq-in-node

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM