

Intro to Node on AWS Lambda for S3 and Kinesis - nicksergeant
http://eng.localytics.com/taming-aws-lambda-for-s3-and-kinesis-at-localytics/

======
icpmacdo
Is there a way to automatically kill Lambda if the cost is going out of
control because of an infinite loop? As a solo dev I cant be willing to bet
hundreds or thousands of dollars potentially lost because of a bad piece of
code I wrote. If thats possible it seems like a nice service that will save a
lot of time not having to worry about doing server administration.

My ask HN post from earlier today basically asking the same thing
[https://news.ycombinator.com/item?id=9520964](https://news.ycombinator.com/item?id=9520964)

~~~
kondro
Lambda functions can execute for a maximum of 60 seconds.

~~~
nicksergeant
But, if you have more than one Lambda working on a single S3 bucket, for
example, it's possible to trigger executions infinitely.

Edit: my mistake - you still can't have multiple lambdas operating on a single
S3 bucket. I had triggered an infinite loop by manipulating files in the same
bucket that it was triggered on (triggering another execution, infinitely).

~~~
helper
Last time I checked, you could only have one Lambda function attached to
bucket events at a time.

~~~
nicksergeant
Yep, but if your lambda creates a new file in that bucket, it'll get called
again (as an example).

Edit: realized my mistake in the wording of my comment above - _how_ I made
the infinite loop had escaped me for a moment.

~~~
res0nat0r
I believe when you upload your code it will throw an error that your source
and destination bucket are the same, which will prevent this type of looping.

~~~
gamache
This is not the case. I've written a Lambda which quite purposefully writes to
a different path in the source bucket.

I have a Lambda for processing large files; the first phase is a single Lambda
splitting the file into chunks which can be processed within the 60 second
limit, and then the second phase is a bunch of the same Lambdas processing
those chunks.

(Disclosure: I work with nicksergeant at Localytics.)

------
kennu
I wish Lambda could listen to arbitrary TCP ports and respond e.g. to HTTP
requests or MQTT messages. In the current form it seems pretty limited for any
scenarios where generic clients initiate the requests, such as collecting
device data and metrics. As I understand, currently the clients have to speak
AWS-specific protocols to submit events / data.

~~~
justincormack
The impression I get is that it is not really realtime, I am guessing all
requests get queued and then scheduled on to a suitable host soon, but perhaps
not within the time to respond to a TCP request.

(Although custom events
[http://docs.aws.amazon.com/lambda/latest/dg/walkthrough-
cust...](http://docs.aws.amazon.com/lambda/latest/dg/walkthrough-custom-
events-invoke.html) suggest its pretty close to real time; should measure the
latency).

------
cddotdotslash
I really wish AWS would open up Lambda to more events than just S3 uploads and
SQS / Dynamo queues. There are so many workloads I could move to Lambda if I
could just invoke it via an API call.

~~~
cherioo
You mean this? [http://docs.aws.amazon.com/lambda/latest/dg/walkthrough-
cust...](http://docs.aws.amazon.com/lambda/latest/dg/walkthrough-custom-
events-invoke.html)

