Alex Craft
Alex Craft

Reputation: 15336

AWS Lambda for unsafe user scripts with node.js?

Would it be possible to use AWS Lambda to run unsafe user scripts? It should be:

Would it be efficient? Like for example you have let's say 5000 different scripts and every one of it get executed once for every 1-30 sec?

How much more would it cost compared to do the same using usual AWS instance? Order of magnitude precision would be fine, like saying "it will cost you no more than 10x same on usual AWS instance" would be good enough.

Upvotes: 0

Views: 106

Answers (1)

Udo Held
Udo Held

Reputation: 12548

It doesn't sound like a very good use case to me.

Lambda containers get reused. Generally you can use all functionality your programming language offers including timers. They will get freezed between executions, but would probably resume on reuse. Some languages might allow you to limit the scripts content. I remember that with PHP servers could prohibit the calling of certain functions, but I assume that you couldn't configure that using Lambda. If you would want real isolation you will have to setup one Lambda Function for each script. This could be done automatically, but still sounds like a mess to me. If you isolate each script, you have to take into account the time needed for the first execution which could be slow and the time required if the Lambda function hasn't been called for a while.

Lambda has some limits of which some can be increased some cannot. You could hit the increase-able concurrent executions.

Somehow you would have to trigger your Lambdas. You could use Cloudwatch for it.

As you already figured out you can limit memory and execution time. Price-wise you only pay what you actually use, which is usually much cheaper than having instances running half idle most of the time. If you fully utilize the EC2/Elastic Beanstalk instances they would be cheaper.

Updated: Pricing is $0.00001667 per GB-second billed in 100 ms blocks plus a request fee of $0.20 per 1 million requests after a generous free tier.

Upvotes: 2

Related Questions