一起使用pm2和docker有什么意义? [英] what is the point of using pm2 and docker together?

查看:1179
本文介绍了一起使用pm2和docker有什么意义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经非常成功地使用pm2在服务器上运行应用程序.我们目前正在使用docker,我们看到了 http://pm2.keymetrics.io /docs/usage/docker-pm2-nodejs/

We have been using pm2 quite successfully for running apps on our servers. We are currently moving to docker and we saw http://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/

但是同时使用两者又有什么意义呢?码头工人不提供pm2所做的一切吗?

But what is the point of actually using both together? Does not docker provide everything pm2 does?

推荐答案

通常,在docker内部使用pm2毫无意义.

Usually there is no point in using pm2 inside of a docker.

PM2和Docker都是流程管理器,它们都可以执行日志转发,重新启动崩溃的工作程序以及许多其他事情.如果您在docker容器中运行pm2,则您的服务将隐藏潜在的问题,至少要遵循以下条件:

Both PM2 and Docker are process managers and they both can do log forwarding, restart crashed workers and many other things. If you run pm2 inside of a docker container you will hide potential issues with your service, at least following:

1)如果您使用pm2在每个容器上运行一个进程,那么除了增加内存消耗之外,您将不会获得太多收益.可以使用具有重启策略的纯docker完成重启.其他基于docker的环境(例如ECS或Kubernetes)也可以做到这一点.

1) If you run a single process per container with pm2 you will not gain much except for increased memory consumption. Restarts can be done with pure docker with a restart policy. Other docker based environments (like ECS or Kubernetes) can also do it.

2)如果您运行多个进程,则将使监视更加困难. CPU/内存指标不再对您的封闭环境直接可用.

2) If you run multiple processes you will make monitoring harder. CPU/Memory metrics are no longer directly available to your enclosing environment.

3)对单个PM2流程进行健康检查的请求将在工人之间分配,这很可能隐藏不健康的目标

3) Health checks requests for a single PM2 process will be distributed across workers which is likely to hide unhealthy targets

4)pm2隐藏了工伤事故.您几乎不会从监视系统(如CloudWatch)中了解它们.

4) Worker crashes are hidden by pm2. You will hardly ever know about them from your monitoring system (like CloudWatch).

5)负载平衡变得更加复杂,因为实际上您将具有多个级别的负载平衡.

5) Load balancing becomes more complicated since you're virtually going to have multiple levels of load balancing.

在docker容器中运行多个进程也与docker的理念相反,即每个容器仅保留一个进程.

Also running multiple processes inside of a docker container contradicts the philosophy of docker to keep a single process per container.

我能想到的一种情况是,您对Docker环境的控制非常有限.在这种情况下,运行pm2可能是控制工作人员调度的唯一选择.

One scenario I can think of is if you have very limited control over your docker environment. In this case running pm2 may be the only option to have control over worker scheduling.

这篇关于一起使用pm2和docker有什么意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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