pwmetrics-lambda
Run pwmetrics on AWS Lambda.
Last updated 3 years ago by chriszarate .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install pwmetrics-lambda 
SYNC missed versions from official npm registry.

PWMetrics on AWS Lambda

This package allows you to run PWMetrics on AWS Lambda (Node 6.10.3), using a binary compiled specifically for that platform (from the Serverless Chrome project).

Usage

npm install --save pwmetrics-lambda

This package exports a function that wraps PWMetrics—see that package’s documentation for details on parameters and options. Like PWMetrics, it returns a Promise for the results of the the test(s).

Example Lambda function

This function accepts a URL to test and PWMetrics options from the Lambda event payload.

const lambdaPWMetrics = require('pwmetrics-lambda');

exports.handler = (event, context, callback) => {
	const { options, url } = event;

	lambdaPWMetrics(url, options).then(results => {
		// Do something with results.
		callback(null, results.runs);
	}).catch(callback);
};

Important considerations:

  • Increase the timeout to at least 15 seconds. Adjust as needed.

  • Increase the allotted memory to at least 768 MB. Adjust as needed. Resource- intensive pages may require considerably more memory.

  • Implement a catch method that calls the Lambda callback in case of a problem with the test.

  • The Chrome binary is quite large (~100 MB)—too big to upload directly to Lambda. You will need to sideload your function via S3. Most frameworks (e.g., Serverless, Claudia) support this either automatically or via options.

Testing locally

Because PWMetrics uses Lighthouse to launch Chrome, you can run it locally and Lighthouse should find and use a local copy of Chrome.

Current Tags

  • 1.0.0                                ...           latest (3 years ago)

1 Versions

  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |