Monday, 3 February 2020

Running the same Puppeteer script twice at the same time doubles the process time for each request. Why?

Hey everyone!I'll give you a bit of a small explanation below, and I hope this is the right place to post this since I've narrowed down my issue to node. I have a PHP application that's using a wrapper package for Puppeteer. The script it's calling, is this: https://github.com/spatie/browsershot/blob/master/bin/browser.jsIf I ssh into my server and run the script manually with node:/usr/bin/node /var/www/html/vendor/spatie/browsershot/bin/browser.js '{"url":"https://google.com","action":"pdf","options":{"args":["--no-sandbox","--disable-setuid-sandbox"],"viewport":{"width":800,"height":600},"executablePath":"/usr/bin/chromium-browser","format":"A4"}}' It takes around ~2 seconds to return back what I expect.However, if I stack the requests on top of each other using two separate ssh sessions, and start them both at the same time, each one takes ~4 seconds to return back. And this increases the more requests/tabs that I use (e.g. 3 tabs = 6 seconds each, and so on).My question is, is this normal behavior? Is there something in that script, or something that I can set manually on my server to run this more concurrently? Please feel free to ask me any questions that might help you understand this better!

Submitted February 03, 2020 at 08:31PM by aschmelyun

No comments:

Post a Comment