fireproofsocks

fireproofsocks

I’m not a Lambda fan-boy because I think it’s overprescribed as a cure-all for every possible problem when in reality, Lambdas are best suited for a narrower scope of tasks. Generally I wouldn’t think any VM-centric language would be a good fit for a Lambda because they would have a larger footprint and may take longer to start, but Java has been one of the Lambda options for a long time. So… clearly there’s more to the story.

Anyhow, because Lambdas often get brought up any time there’s a conversation about “serverless” deployments, I think they are a worthy topic of discussion.

There’s an old thread about Elixir on AWS Lambda: Elixir on AWS Lambda is coming soon

but I haven’t seen much on it recently. There’s even the aws_lambda_elixir_runtime Hex package, but it hasn’t been updated in quite a while (e.g. it uses Distillery instead of releases).

Ironically, I have had to think a lot MORE about the infrastructure when I use tools like serverless. However, one can’t ignore the push towards deploying apps in the context of various cloud services, so IaC tools are hard to ignore. I’m curious what people are thinking or have seen with respect to Elixir deployments and Elixir as a service. It would be nice to have easier deployments. Gigalixir is a great platform-as-a-service, but I’m wondering if there’s room for more tooling something that might a bit more like serverless or chalice that deals with automating the painful AWS permissions around getting something deployed.

Showing Posts 1 to 9

Sebb

Sebb

The startup is only an issue if you have few requests and the lambda has to cold-start. You can keep the lambda “warm” to not have to cold-start.

But I would not use Elixir as a lambda. It seems a little hacky. But more important, lambdas are usually used as very specialized functions. You have to build a system around it. Elixir/OTP is very good at just that: building a system. You’d give that up and make everything more complicated than needed. Depends on the use case obviously.

fireproofsocks

fireproofsocks OP

Agreed. I guess I’d say the same thing about Lambdas used as a webserver with routes etc. I’d rather have a on-demand EC2 instance or something. I wonder if you could have a BEAM instance running and have ad-hoc modules hot-loaded into it as needed. That’s really getting out there though…

dergraf

dergraf

Not an answer, more of an experience report :wink:

I’ve played at some point with AWS Lambdas written in Elixir, first by using one of the mentioned libraries and second by rolling it on my own using just HTTPoison. It made me realize how simple the architecture actually is or can be (assuming the official Lambda stacks do more or less the same as I did).

But that was only an experiment. Today we live with a mixed codebase of Javascript and Python based Lambdas used as custom Authorizers in AWS API Gateway. All our Lambdas are deployed using Terraform aws_lambda_function module. To make this work with plain Terraform we must store the Lambda dependencies, e.g. JS node_modules folder, in the same directory as the actual Lambda code, all checked into Git. :weary:

Separating the Lambda code from Terraform could solve this issue, which would be possible with the other Lambda flavors; deployment packages on AWS S3 or container images on AWS ECR. In contrast to the simple zip based approach, one must introduce a whole new process to separately test, build, and deploy those artifacts (but that’s what we do for our Elixir apps anyways, right).

I think if a Lambda codebase gets bigger, their dependencies more complex, using a separate CI/CD process for Lambdas outside of IaC becomes inevitable. We’re not at this point yet, but once we are, I would definitely do another round of experimentation with Elixir based Lambdas.

Sebb

Sebb

lambda deployment is not fun. We use serverless, thats ok.

WilliamSpain

WilliamSpain

Hi @dergraf, if you can remember what you did, would you be able to elaborate on how you managed to get elixir running on AWS Lambda for even a basic Hello World response. I have been trying something similar but struggled to get something running that didnt seem extremely hacky.

Im not a super proficient Elixir programmer but I was trying to use escript, burrito, and distillery, however with my approach runs into errors such as the following when I test my function.

/var/task/erts-15.1.2/bin/epmd: /lib64/libc.so.6: version `GLIBC_2.38' not found (required by /var/task/erts-15.1.2/bin/epmd)
/var/task/erts-15.1.2/bin/beam.smp: /lib64/libgcc_s.so.1: version `GCC_12.0.0' not found (required by /var/task/erts-15.1.2/bin/beam.smp)

Im hesitant to just jam in more dependencies as it feels like the wrong approach and it looks like my zip folder for my lambda will be significantly larger than what I was able to do when I tried the same in Haskell.

dergraf

dergraf

Hi!

I was using a containerized lambda instead of the classic zip file, see Create a Lambda function using a container image - AWS Lambda. this requires the containerized application to poll the AWS Lambda runtime for requests to be run, this is done using a Lambda runtime client, several libraries exists for this, but honestly it’s (was) two separate HTTP requests that were very straightforward to implement.I think I’ve started with this library GitHub - aws-samples/aws-lambda-elixir-runtime: Example implementation of a custom runtime for running Elixir on AWS Lambda. · GitHub.

Best,

StorageCluster

StorageCluster

there has been an update on the Elixir “native” on AWS Lambda. There is a project by @bmalum called Mayfly - just discovered it on https://elixir-aws-lambda.dev works well - sadly no Hex Package yet but runs with Elixir 1.19.3

StorageCluster

StorageCluster

just tested it in production - cold start execution seems fine with Mayfly which was 1.2s for me compared to Java Lambda it is very good, to native Node v22 it is “slow” which is 315ms. Every “warm” execution was <2ms for “Hello Elixir” Sample, which is was even faster than the native Node 22 Lambda (same output) at 3ms. @bmalum if you are still active here - maybe can you add a benchmark to the website?

bmalum

bmalum

Got your mention notification, thanks for advertising it. The project will be published on Hex.pm in the future. Benchmarks are a great idea – if time permits, I plan to put together a small comparison to make the trade-offs more transparent.

Cold starts are definitely a topic, but in my tests with larger applications they were consistently below 2 seconds. If that is still an issue and you want to stay with Elixir on AWS Lambda, using provisioned concurrency (around $4.50/month for a single always-warm instance) effectively eliminates the cold start problem. For my use case, the cold start overhead is acceptable and does not impact the workload significantly

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
Herve37
We’re evaluating API mocking tools for OpenAPI-based projects and would love to hear what other teams are using. We’re particularly inte...
New
matt-savvy
Is there a word for the ~> symbol used in Version strings? Do you also just call it a Squiggle Arrow™ ?!
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews