Using Elm as a backend on AWS Lambda

1,287 views
Skip to first unread message

Robin Heggelund Hansen

unread,
Nov 26, 2015, 2:11:54 PM11/26/15
to Elm Discuss
AWS Lambda is a service that allows you to run a single function in the cloud. Combining this with a service like API Gateway, you can have a scalable and cheap backend service, written in a JS-compatible language.

I did some experimentation yesterday on using Elm on AWS Lambda. I was successful, look at the following gist: https://gist.github.com/Skinney/610447ce20bf25d7c8bb

One still need bindings to the aws js api for it to be truly useful, but this is a cool start.

I noticed that a simple PING->PONG program in JS ran in 4-10ms, while including Elm made the response time increase to around 20-40ms. I assume this is due to initialising the Elm runtime, and I also think this will improve significantly in the next release with the new native format, new code generation and DCE lands in the compiler.

Noah Hall

unread,
Nov 26, 2015, 2:30:12 PM11/26/15
to elm-d...@googlegroups.com
I have a web server PoC here - https://github.com/eeue56/servelm which
you might interested in
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Robin Heggelund Hansen

unread,
Nov 26, 2015, 2:37:15 PM11/26/15
to Elm Discuss
Looks cool. My goal was to get something up in Lambda though.

Vladimir Lobyntsev

unread,
Nov 27, 2015, 12:37:54 AM11/27/15
to Elm Discuss
Very interesting! Who else can share the experience?

пятница, 27 ноября 2015 г., 1:11:54 UTC+6 пользователь Robin Heggelund Hansen написал:

Tim Stewart

unread,
Jan 19, 2016, 10:31:58 PM1/19/16
to Elm Discuss
I'm just staring to have a look at Lambda, and a functional language like Elm could be an interesting fit in this "functional cloud" context. Robin, when you speculated that the next Elm version should be quicker on Lambda, were you referring to 0.16 (now released) or is this still in the works?

Thanks
Tim

Conrad Dean

unread,
Jan 19, 2016, 11:49:17 PM1/19/16
to Elm Discuss

the thread related to this guy's tweet re: lambda and a compile-to-js language pretty relevant: https://twitter.com/puffnfresh/status/689303145760051200?s=09


Robin Heggelund Hansen

unread,
Jan 20, 2016, 6:37:12 AM1/20/16
to Elm Discuss
Tim: I was referring to 0.17 which, according to some posts on the elm-dev mailing list, will produce code that minifies better (less code to parse), will include dead-code removal (less code to parse) and a new native format which I believe will have less need of bootstraping (less code to run after parse). Smaller code should also make it faster to transfer, meaning cold startup should improve.

Of course, those things might not provide a noticable performance improvement though. My tests weren't very scientific, so lambda could simply have had a bad day.

Conrad: The lack of higher-kinded types, or any interface-like construct, is a criticism of Elm completely unrelated to aws lambda, and is very specific to Elm, not all compile-to-js languages.

Daniel Bachler

unread,
Jan 20, 2016, 7:34:56 AM1/20/16
to Elm Discuss
Just as an aside, if you want to run a functional compile-to-js language on AWS lambda, purescript might be closer to what you want (if you compare it with Elm today, not soem future version). I have seen at least one blog post of someone doing this and am thinking of going down that road myself (currently the lambda code is very little and written in vanilla JS but purescript might be nice for the more complex things to come).

Ryan Bell

unread,
Jan 20, 2016, 8:32:33 AM1/20/16
to Elm Discuss
Here's my blog post on Purescript in Lambda, if anyone is interested: http://kofno.github.io/2015/10/11/aws-lambda-purescript.html


Tim Stewart

unread,
Jan 21, 2016, 1:28:23 AM1/21/16
to Elm Discuss
Thanks Robin, it will certainly be interesting to see if these changes affect real-world performance. As for PureScript, having watched a few conference videos and read a bit of this:


I'm not convinced it can be as approachable and productive as Elm. As someone who's approaching FP from a more imperative / procedural / OO background I find Elm's simplicity to be very attractive. But maybe Elm's simplifying abstractions - particularly lack of inheritance (I think that's what you mean by higher-kinded types?) or interfaces - might be a problem. It certainly does seem to be for making generic, composable widget hierarchies.

Thanks
Tim

Kevin Tonon

unread,
Feb 1, 2017, 12:04:11 PM2/1/17
to Elm Discuss
I've been working on a simple framework for writing http servers in elm, which can be deployed to aws lambda. Up to date with elm 0.18. Not much in the way of middleware yet. And AWS SDK bindings for elm are still unimplemented (but that is on my roadmap). https://github.com/ktonon/elm-serverless
Reply all
Reply to author
Forward
0 new messages