I would like to run Clojure in an AWS Lambda with minimal startup time. It seems that would be a good use for GraalVM's native-image. Any disagreements there? Any experience reports? Any good docs or instructions you've found on doing that? Thanks!
How would you define minimal startup time? Have you tested how much you can cut from startup time by using direct linking, AOT, removing metadata, etc?
@ben.sless I have not tested those things. I only have the impression that Graal makes things fast. However, building with Graal does not seem to be trivial, so I may revert to Java
Building with a Native Image does significantly reduce start up time, however, the generated binary, by the Community Edition at least, performs worse than a JVM run would after the JIT has warmed up, so you need to consider the run time of the application itself. If it's under a few seconds a native image would probably be better. From minutes upwards a JVM would be better. Building a native image used to be harder but the Clojure community has figured out the big parts, so unless you're doing something weird or radical, it should be simple. Maybe just a bit resource intensive.
That's a recurring topic in #babashka channel, as it fits the bill perfectly in most cases2👍
But even using clojure itself and compiling it via graalvm might be a good way.
Depending on the tasks you need to do (and libraries you want to use), using
graalvm might give you lower footprint and probably better performance if it's important for you. But at a cost of rather slow build times, as
native-image compilation is waaay slow. What's nice about babashka is that it already comes in natively-compiled form.
Ahh, cool, I will see if babashka will meet my needs, thanks!
check this thread from yesterday, started by lukasz 🙂 https://clojurians.slack.com/archives/CLX41ASCS/p1618416923161500
It supports both java runtime and native one. This month I'm adding support for interceptor chain & GraalVM EE. Docs are lacking tbh, but @ekoontz is working on it. 🙂
You can find examples in /examples folder. If you need some help with starting out then let me know :)