微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

pm2 start -i max run on 12 vcpu 买我的ec2只有8个vcpu

如何解决pm2 start -i max run on 12 vcpu 买我的ec2只有8个vcpu

我刚刚将我们的 AWS EC2 实例从 t2.xlarge 升级t2.2xlarge,所以我们的实例现在有 8 个 vcpu。重新启动服务器后,我运行命令 pm2 start src/app.js -i max -f,令我惊讶的是,我的应用程序现在运行在 12 个 vcpu 上,而不是在 8vcpu 上运行。至少这就是 pm2 list 显示内容。这里到底发生了什么?

enter image description here

这是cat /proc/cpuinfo输出

processor       : 7
vendor_id       : GenuineIntel
cpu family      : 6
model           : 79
model name      : Intel(R) Xeon(R) cpu E5-2686 v4 @ 2.30GHz
stepping        : 1
microcode       : 0xb000038
cpu MHz         : 2300.118
cache size      : 46080 KB
physical id     : 0
siblings        : 8
core id         : 7
cpu cores       : 8
apicid          : 14
initial apicid  : 14
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov                 pat pse36 clflush mmx fxsr sse sse2 ht syscall nx pdpe1gb rdtscp lm constant_tsc                 rep_good nopl xtopology cpuid pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x                2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_                lm abm cpuid_fault invpcid_single pti fsgsbase bmi1 avx2 smep bmi2 erms invpcid                 xsaveopt
bugs            : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds                 swapgs itlb_multihit
bogomips        : 4600.13
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical,48 bits virtual
power management:

解决方法

我们在评论中讨论的内容摘要。

cat /proc/cpuinfo 的输出告诉我们,实例实际上有 8 个 CPU 内核,我们可以从这一行看到:

cpu cores       : 8

这告诉我们 AWS 为您提供了您所支付的费用:-)

我对 pm2 一无所知,但是 docs 告诉我,-i max 中的 pm2 start src/app.js -i max -f 告诉 pm2 启动与 CPU 内核数一样多的工作进程。>

当您更改实例类型时,CPU 内核检测似乎以某种方式搞砸了,它选择将新的 8 个内核添加到它已经知道的 4 个内核中,现在为您提供 12 个进程。

作为一种解决方法,您可以像这样将工作进程的数量显式设置为 8:

pm2 start src/app.js -i 8 -f

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。