使用throng 加速nodejs 应用的并行执行能力

使用throng 可以简化nodejs 的多cpu任务执行处理,代码简洁
基于worker_threads 也是一个不错的选择

参考使用

 
const throng = require('throng')
throng(id => console.log(`Started worker ${id}`))

说明

throng 还是比较强大,内部基于了node 的cluster

参考资料

https://github.com/hunterloftis/throng
https://github.com/pioardi/poolifier
https://cube.dev/blog/jobber-runs-on-cubejs/
https://devcenter.heroku.com/articles/node-concurrency

原文地址:https://www.cnblogs.com/rongfengliang/p/14215516.html