Clojure on AWS Lambda?

766 views
Skip to first unread message

Kyle Sexton

unread,
Jun 15, 2015, 4:07:29 PM6/15/15
to clo...@googlegroups.com
Curious if anyone is doing anything on AWS Lambda now that it supports running Lambda functions in Java, https://aws.amazon.com/blogs/aws/aws-lambda-update-run-java-code-in-response-to-events/ ?


Kyle Sexton

Jason Lewis

unread,
Jun 15, 2015, 8:46:58 PM6/15/15
to clo...@googlegroups.com
I'm actually really curious about this as well, I've been wanting to experiment with AWS Lambda but the slow start-up of the Clojure runtime on the JVM has made me apprehensive... is there some mitigation of this on the Lambda service?

On Mon, Jun 15, 2015 at 4:07 PM Kyle Sexton <k...@mocker.org> wrote:
Curious if anyone is doing anything on AWS Lambda now that it supports running Lambda functions in Java, https://aws.amazon.com/blogs/aws/aws-lambda-update-run-java-code-in-response-to-events/ ?


Kyle Sexton

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Karsten Schmidt

unread,
Jun 16, 2015, 2:13:10 AM6/16/15
to clo...@googlegroups.com
Maybe Clojure itself isn't suitable, but Clojurescript w/ node as
target and lein-npm[1] should be okay (not tested)... Alternatively,
if you really need JVM features, you might be able to give Skummet[2]
a try (and please report back!)

[1] https://github.com/RyanMcG/lein-npm
[2] http://clojure-android.info/skummet/
--
Karsten Schmidt
http://postspectacular.com | http://thi.ng | http://toxiclibs.org

Ragnar Dahlén

unread,
Jun 16, 2015, 9:36:00 AM6/16/15
to clo...@googlegroups.com
I gave it a go:

It's just a POC. Needed a Java shim to manage class loaders so the interface is not as nice I was hoping.

Might make it into library if there's interest.

Kyle Sexton

unread,
Jun 16, 2015, 10:43:22 AM6/16/15
to Ragnar Dahlén, clo...@googlegroups.com
Nice work! Can you give any indication of what performance is like?


Kyle Sexton

Kyle Sexton

unread,
Jun 16, 2015, 11:46:36 AM6/16/15
to Ragnar Dahlén, clo...@googlegroups.com

Answering my own question about performance, it looks like almost 14 seconds for the Lambda function to run. Doing the math1 if I were to run this 3000000 times in a month bill would be about $342.56. Probably not the ideal solution for clojure in the cloud just yet. :)

START RequestId: 48614bcd-143b-11e5-b2c5-b704df8ab2eb
HELLO FROM CLOJURE :)
#object[lambdainternal.api.LambdaClientContext 0x26a7b76d lambdainternal.api.LambdaClientContext@26a7b76d]
END RequestId: 48614bcd-143b-11e5-b2c5-b704df8ab2eb
REPORT RequestId: 48614bcd-143b-11e5-b2c5-b704df8ab2eb	Duration: 13680.53 ms	Billed Duration: 13700 ms 	Memory Size: 512 MB	Max Memory Used: 104 MB

Kyle Sexton

Footnotes:

Footnotes:

1

Used http://aws.amazon.com/lambda/pricing/ and came up with (* (* (* 13.7 3000000) (/ 512 1024.0)) 0.00001667) where 3000000 is number of times run per month, 13.7 is seconds of billable time, 512 is MB of RAM allocated to the function.

Ragnar Dahlén

unread,
Jun 17, 2015, 3:28:50 AM6/17/15
to clo...@googlegroups.com, r.da...@gmail.com
You can get the initial startup time down by AOT compiling. I also believe that Lambda will re-use the same runtime and lambda function instance until a certain period of inactivity.

For example, in the example below I invoke the function (AOT compiled this time) three times. First invocation takes ~7s, the two following ~1.5ms.


START RequestId: b555c9c2-14c1-11e5-8a31-03153568534c
HELLO FROM CLOJURE :)
#object[lambdainternal.api.LambdaClientContext 0x3419866c lambdainternal.api.LambdaClientContext@3419866c]
END RequestId: b555c9c2-14c1-11e5-8a31-03153568534c
REPORT RequestId: b555c9c2-14c1-11e5-8a31-03153568534c Duration: 7882.62 ms Billed Duration: 7900 ms Memory Size: 512 MB Max Memory Used: 98 MB
START RequestId: bd876a51-14c1-11e5-94fc-f9606cb38b63
HELLO FROM CLOJURE :)
#object[lambdainternal.api.LambdaClientContext 0x63e31ee lambdainternal.api.LambdaClientContext@63e31ee]
END RequestId: bd876a51-14c1-11e5-94fc-f9606cb38b63
REPORT RequestId: bd876a51-14c1-11e5-94fc-f9606cb38b63 Duration: 1.66 ms Billed Duration: 100 ms Memory Size: 512 MB Max Memory Used: 98 MB
START RequestId: bdf4aa6f-14c1-11e5-a6b0-e9e3f6fa14c8
HELLO FROM CLOJURE :)
#object[lambdainternal.api.LambdaClientContext 0x68fb2c38 lambdainternal.api.LambdaClientContext@68fb2c38]
END RequestId: bdf4aa6f-14c1-11e5-a6b0-e9e3f6fa14c8
REPORT RequestId: bdf4aa6f-14c1-11e5-a6b0-e9e3f6fa14c8 Duration: 1.56 ms Billed Duration: 100 ms Memory Size: 512 MB Max Memory Used: 98 MB

Moe Aboulkheir

unread,
Jul 5, 2015, 7:33:46 AM7/5/15
to clo...@googlegroups.com
I looked into this a little over the weekend, and wrote a small library & lein template/plugin for deploying Clojurescript functions to Lambda: https://github.com/nervous-systems/cljs-lambda


Take care,
Moe

--
Reply all
Reply to author
Forward
0 new messages