Is it safe to run multiple instances of Puppeteer at the same time?

后端 未结 3 1664
小蘑菇
小蘑菇 2021-02-01 20:50

Is it safe/supported to run multiple instances of Puppeteer at the same time, either at

  1. the process level (multiple node screenshot.js at the same ti
3条回答
  •  滥情空心
    2021-02-01 21:21

    Each puppeteer.launch() boots a new browser for your script to drive, so it's better to have a script interact with multiple puppeteer.launch calls versus running multiple instances of your script. Even though node is single-threaded, events are sent through WebSockets to the browser, meaning you're benefiting from node's async behavior. Said another way: none of these processes run in serial and instead run in parallel even given the single-threaded nature.

    For some background I run a service called browserless (https://browserless.io) that aims to productionalize web-based work. I also maintain a few images on docker here: https://hub.docker.com/r/browserless/chrome/

提交回复
热议问题