lambda-job / 1.0.0 last updated 3 days ago created on Dec 28th 2014
Install
npm install --save lambda-job
Clone
git clone git@github.com:lg/lambda-job.git
dependencies
| main |
|
aws-sdk | 2.1.4 | Apache 2.0 |
maintainers
larrygadea
versions
| 1.0.0 | 3 days ago | larrygadea |
readme
LambdaJob
LambdaJob provides real-time invoking and completion detection of AWS Lambda functions from JavaScript on the clientside's web browser. This makes it easy to scale things like: scraping websites, thumbnail generation of images/videos, running custom binaries, etc.
Features
- Lambdas triggered by S3 Object creation
- Real-time results via SQS long-polling
- No back-end needed, just an AWS account and public IAM permissions
- Low-latency and performance focus throughout
- Maximum job throttling (to stay under the 25 Lambda limit)
- Shared SQS queue per client
- Helper for calling commandline applications on Lambda
Usage
From the web browser:
The Lambda job:
Outputs in the web browser:
Options
debugLog: Turn debug logging on/off. Useful to turn on to see how LambdaJob works. (default: false)maxActiveJobs: Throttle how many jobs can run at once. Note AWS has a hard limit of 25 active jobs at any one point. (default: 25)jobTimeout: The maximum amount of time (in ms) that a job can run for. (default: 30000)s3BucketPrefix: Since we create S3 objects for every desired job, the bucket they're inside of has this prefix. Note that S3 buckets are in a global namespace with other people. (default: lambda-job-)sqsQueuePrefix: Like the s3BucketPrefix except for SQS queues. (default: lambda-job-)
Prerequisites
Create an IAM user with the following permissions:
- Create an S3 bucket named
lambda-job-LAMBDANAME Add CORS permissions on the S3 bucket. Here's a CORS config sample:
- Create your Lambda and set this S3 bucket as your S3 source. It's recommended to use the full 1024MB of RAM since it seems things are faster this way.
- In your Lambda, upload your files to AWS, making sure you included the npm modules you'll need in the archive.
- Browse to index.html either where you've hosted it, or locally.
Examples
- bash shows how you can run custom binaries on Lambda. It also provides convenient access to explore the Lambda VM and what's available.
- nomocors shows how you could use LambdaJob to proxy around CORS restrictions. Great for client-side automation.