These are the advantages of each method in my opinion:
Advantage of multiple browsers:
- Separate processes: If one browser crashes, the other browsers keep running
Advantage of one browser (with multiple pages):
- Less memory usage: Although in reality memory and CPU usage depends to a high degree on the task you are doing (screenshot, DOM manipulation)
- The cookies (and other data) are shared
There is also the option to use multiple contexts, which needs less memory than two separate browsers, but does not share cookies.
So in reality, you should probably just give both options a try. You might want to have a look at the library puppteer-cluster I wrote, which also takes care of error handling and browser restarting in case of crashes.
You can just write your code and switch between multiple browsers vs multiple pages with just one line:
const cluster = await Cluster.launch({
concurrency: Cluster.CONCURRENCY_PAGE, // which kind of concurrency
maxConcurrency: 2, // number of parallel workers
});
Just replace CONCURRENCY_PAGE
with CONCURRENCY_BROWSER
to give multiple browser a try. There is also a third option CONCURRENCY_CONTEXT
you might want to try.