Unable to Run Multiple Node Child Processes without Choking on DigitalOcean

只愿长相守 提交于 2019-11-27 06:31:31

问题


I've been struggling to run multiple instances of Puppeteer on DigitalOcean for quite some time with little luck. I'm able to run ~5 concurrently using tools like puppeteer-cluster, but for some reason the whole thing just chokes with little helpful messaging. So, I switched to spawning ~5 child processes without any additional library -- just Puppeteer itself. Same issue. Chokes with no helpful errors.

I'm able to run all of these jobs just fine locally, but after I deploy, I hit these walls. So, my hunch is that it's a resource/performance issue, but I can't say for sure.

I'm running a droplet with 1GB and 3CPUs on Digital Ocean.

Basically, I'm just looking for ways to start troubleshooting something like this. is there a way I can know for sure that I'm hitting resource walls? I've tried pm2 and the DO dashboard graphs, but I feel like those are all leaving a lot of information out, or else I'm missing something else altogether.


回答1:


Author of puppeteer-cluster here. You are right, 1 GB of memory is likely not enough for running 5 browser windows (or tabs) in addition to your operating system and maybe even other background tasks.

Here is a list of resources you should check:

  • Memory: Use a tool like htop to check your memory usage while your application is running.
  • CPU: Again, you can use htop for that, 3 vCPUs should be more than enough for 5 windows.
  • Disk space: Use a tool like df to check if there is enough space on the disk. I know of multiple cases in which there was not enough space on the disk (like some old kernels filling the disk), and Chrome needs at least some space to run.
  • Network throughput: Rarely the problem, but sometimes the network just does not have the bandwidth to support many open browser. Use a tool like nload to check the network throughput.

To use htop or nload, you start your script in the background (node script.js &) or use a terminal multiplexer (like tmux). Resource problems should then be easy to spot.




回答2:


Most probably you're running out of memory, 5 puppeteer processes are a lot for a 1GB VM.

You can run

grep -i 'killed process' /var/log/messages

to confirm that the OOM killer terminated your processes.



来源:https://stackoverflow.com/questions/57280441/unable-to-run-multiple-node-child-processes-without-choking-on-digitalocean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!