在 Heroku dyno 上运行多个进程是否可行? [英] Is it feasible to run multiple processeses on a Heroku dyno?

查看:40
本文介绍了在 Heroku dyno 上运行多个进程是否可行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 Heroku 平台的内存限制,并且我知道将应用程序分离为 web 和 worker dynos 更具可扩展性.但是,出于测试目的,我仍然希望在 Web 进程旁边运行异步任务.Dynos 很昂贵,我想在 Heroku 提供的免费实例上进行原型设计.

I am aware of the memory limitations of the Heroku platform, and I know that it is far more scalable to separate an app into web and worker dynos. However, I still would like to run asynchronous tasks alongside the web process for testing purposes. Dynos are costly and I would like to prototype on the free instance that Heroku provides.

在与 Web 进程相同的测功机中将新作业作为进程或子进程生成是否有任何问题?

Are there any issues with spawning a new job as a process or subprocess in the same dyno as a web process?

推荐答案

在较新的 Cedar 堆栈上,生成多个进程没有问题.每个 dyno 都是一个虚拟机,除了内存和 CPU 使用(我认为大约 512 MB 内存和 1 个 CPU 内核)之外没有特别的限制.遵循某些堆栈(例如 Python)的较新安装说明将导致配置具有开箱即用的多个(Web 服务器)进程.

On the newer Cedar stack, there are no issues with spawning multiple processes. Each dyno is a virtual machine and has no particular limitations except in memory and CPU usage (about 512 MB of memory, I think, and 1 CPU core). Following the newer installation instructions for some stacks such as Python will result in a configuration with multiple (web server) processes out of the box.

安装在 web dynos 上的软件可能会因您使用的 buildpack 而异;如果您的子流程需要特殊软件,那么您可能必须将其与您的应用程序捆绑在一起,或者(更好地)推出您自己的 buildpack.

Software installed on web dynos may vary depending on what buildpack you are using; if your subprocesses need special software then you may have to either bundle it with your application or (better) roll your own buildpack.

在这一点上,我通常会提醒您,强烈建议使用适当的任务队列系统在工作人员 dynos 而不是 web dynos 上运行异步任务,但听起来您已经知道这一点.请记住,只有一个 Web dyno 的帐户(通常这意味着免费"帐户)将在一个小时左右未收到任何 Web 请求后使该 dyno 停止运行,并且任何后台进程在该 dyno 上运行时间必然会被扼杀.拥有多个网络 dyno 的帐户不受此限制.

At this point I would normally remind you that running asynchronous tasks on worker dynos instead of web dynos, with a proper task queue system, is strongly encouraged, but it sounds like you know that already. Do keep in mind that accounts with only one web dyno (typically this means, "free" accounts) will have that dyno spun down after an hour or so of not receiving any web requests, and that any background processes running on the dyno at that time will necessarily be killed. Accounts with multiple web dynos are not subject to this restriction.

这篇关于在 Heroku dyno 上运行多个进程是否可行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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