Lighthouse: Lighthouse RESTful API

Created on 5 Jun 2019  路  3Comments  路  Source: GoogleChrome/lighthouse

I am trying to turn lighthouse into a node.js service using express package. Right know, the user can send a request with url address and config file in the POST message and get a full report back (json). The trouble is it is done in a completely blocking way. If two users are sending requests simultaneously then one of them waits like 60 seconds before getting the response (one execution lasts around 30 seconds). Is there a way to scale it somehow inside node js? or the only possibility is to place it in a Docker container and trivially scale it on Kubernetes.

pending-close question

Most helpful comment

You scale it within node by running the CLI as a child_process. There have been a few questions like this before and this seems to be what folks always settle on. Be warned though, unless the server is particularly beefy, running more than one Lighthouse run at a time is going to result it significantly altered performance metrics.

See example code of running Lighthouse in a child process.

Side note: if you want to use Lighthouse as a RESTful API, that's kinda what PageSpeed Insights already gives you ;) https://developers.google.com/speed/docs/insights/v5/get-started

All 3 comments

You scale it within node by running the CLI as a child_process. There have been a few questions like this before and this seems to be what folks always settle on. Be warned though, unless the server is particularly beefy, running more than one Lighthouse run at a time is going to result it significantly altered performance metrics.

See example code of running Lighthouse in a child process.

Side note: if you want to use Lighthouse as a RESTful API, that's kinda what PageSpeed Insights already gives you ;) https://developers.google.com/speed/docs/insights/v5/get-started

Thanks Patrick! I will keep you answer in mind

If you really want to go with your own service, consider adopting a webhook API model. For best results, don't run more than one LH instance at a time.

Was this page helpful?
0 / 5 - 0 ratings