【问题标题】:Run multiple puppeteer executions with puppeteer-cluster使用 puppeteer-cluster 运行多个 puppeteer 执行
【发布时间】:2021-03-04 19:49:11
【问题描述】:

如何使用 puppeteer-cluster 运行多个并发执行?

我有 5 个最大并发,但是 await cluster.execute() 一次只能运行 1 个。

const cluster = await Cluster.launch({
   monitor: false,
   concurrency: Cluster.CONCURRENCY_BROWSER,
   maxConcurrency: 5,
})

for(let url of urls) {
   await cluster.execute(url)
}

我希望所有 5 个都同时执行。另一种方法是 await cluster.queue(),但过了一会儿,内存被吃光了,因为无法检查当前队列长度/大小。

【问题讨论】:

  • 使用cluster.queue(),然后使用await cluster.idle()

标签: javascript node.js concurrency puppeteer puppeteer-cluster


【解决方案1】:

将并发:Cluster.CONCURRENCY_BROWSER 更改为并发:Cluster.CONCURRENCY_CONTEXT

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-27
  • 1970-01-01
相关资源
最近更新 更多