Hello,
I wrote a platform that enables writing AWS Lambda functions with Roc: roc-aws-lambda. It should work pretty well although I have not tested it rigorously. Right now Lambdas can only be compiled on Linux, but I hope to expand that to MacOS also. I had a lot of fun writing the platform and I hope some folks can enjoy using it too. Please open an issue if you run into any! The platform is written in Rust and uses the aws-lambda-rust-runtime under the hood. It is very cool to be able to write lambdas in a language like Roc and still get the excellent startup/runtime performance of the Rust runtime :smiley:
I may write a GitHub actions workflow to build and deploy a lambda. That way non-Linux users could still write them and use roc check locally but not need to compile locally.
That sounds like a great idea. I also wondered if you could have a dockerfile that runs it locally?
Yes that’s a great idea
That is awesome! Nicely done.
I created another repo with a Lambda runtime written in Roc that only uses basic-cli here: roc-aws-lambda-runtime.
I didn't realize this was possible at first and it is better than the platform in many ways: no direct dependency on Rust is necessary, Lambdas can be compiled from non-linux systems easily, it is easy to test your lambda locally, and there is no need to use a different platform than normal. The downside is that right now it is very slow. I'm not sure why it is so slow, and I'm sure it can be sped up, but I have not yet taken the time to look into what is going on.
The runtime depends on some unreleased changes in basic-cli so I've included the platform directly, but it can be moved to a url once a new release of basic-cli is out.
I updated the custom Lambda runtime to basic-cli 18 and the slowness I had seen in the past is now gone :smiley:. I'm very pleasantly surprised that AWS supports writing Lambda functions in Roc in such a lightweight way.
New repo url for the runtime: https://github.com/isaacvando/roc-aws-lambda
I did some very simple benchmarking comparing a hello world lambda in Roc and one in Rust using function urls:
$ artillery quick --count 10 -n 10 <FUNCTION_URL>
I haven't dug into why the tail latency is worse for the Roc function, but there is probably a way to improve it. Regardless, this is very usable.
Roc
http.response_time:
min: 86
max: 182
mean: 111.4
median: 106.7
p95: 156
p99: 179.5
Rust
http.response_time:
min: 83
max: 99
mean: 88.7
median: 87.4
p95: 94.6
p99: 98.5
Wow, awesome
Last updated: Jul 06 2025 at 12:14 UTC