It’s a bit of a sensationalistic title, but hear me out. And sorry for the boring-ish example in this article. This is designed to only excite people who really get it. :)

AWS Lambda lets you run NodeJS code or any binary (or code of any language) as a fast starting and stopping EC2 instance. You can use it to, for example, quickly resize an image as a background worker. What I’ll quickly show you here though is that you could even possibly use it as a full-on back-end for a single-page app.

What’s even more awesome? It basically scales by parallelizing infinitely. No need to ever spin up more EC2 instances or Dynos or any of that. Capacity planning? No need!

So, lets build a quick static webpage (that you can host anywhere, including file://)

Quick page code

All this page does is connect to Lambda and send sup1 as the value to key1 through simple JSON.

Here’s the lambda code (which you literally can do on the AWS Console):

Lambda code

This is even simpler. The handler callback is called by Lambda whenever this Lambda Function is called. context.succeed is used to return a value to the caller.

And lets run it:

Result code

FYI, this is crazy. We just did a backend call with full-on backend logic without setting up any kind of instances. No worrying about starting a new not-even-free-anymore Heroku Dyno. No choosing machine speed and memory and hard drive sizes. It just works, effortlessly, and scales enormously.

One thing you might note is that we’re exposing our AWS public and secret keys. This is actually not that big of a deal. To make this secure, we actually created a new AWS User and with a Policy specifically preventing everything except the one Lambda Function:

Security policy

Oh and I mentioned that it scales “infinitely”, yeah there’s a 100-parallel-requests maximum right now, but I’d imagine this will be removed by AWS as the service matures. Meanwhile, you can ask them for more.

I guess recent AWS changes makes my lambda-job project kinda useless. It’s all built in now.

Very cool stuff. Hat tip to Amazon for constantly doing new amazing things.

thanks to @siong1987 for the quick review