This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-01
Channels
- # announcements (2)
- # babashka (10)
- # beginners (133)
- # calva (28)
- # cestmeetup (1)
- # chlorine-clover (31)
- # cider (21)
- # clj-kondo (29)
- # cljs-dev (252)
- # clojure (60)
- # clojure-europe (24)
- # clojure-nl (3)
- # clojure-spec (13)
- # clojure-uk (17)
- # clojurescript (47)
- # conjure (20)
- # datascript (2)
- # datomic (4)
- # figwheel-main (4)
- # fulcro (71)
- # helix (16)
- # jobs (1)
- # meander (56)
- # mount (1)
- # off-topic (15)
- # pathom (25)
- # re-frame (17)
- # reagent (5)
- # remote-jobs (1)
- # shadow-cljs (92)
- # sql (10)
- # tools-deps (71)
- # xtdb (14)
How long start hello World Clojure app? how long comparing to Java? How long with dependencies? I am asking in context of ‘google cloud run’ so this can matter here. The app need to fully start as fast as possible. I am not sure if Clojure is good for this model. Comparing to for example Rust or Go it can be a difference.
Well, Clojure and Java both need to spin up the JVM, while Rust and Go compile to native executable - the comparison is inherently lacking. If it's just a "hello world" app, that needs to spin up as fast as possible and you're still keen on using Clojure, you can probably do it with GraalVM
Yes comparison is not the best, but trying to figure out if it is good idea to use cloud run or not
It isn't fast enough for serverless, unless you use ClojureScript or you compile Clojure ahead of time to a native executable
Both of those impose some restrictions to your Clojure code. With ClojureScript, well, you can't use any Java dependencies, only JS. And with GraalVM native compilation, not all Clojure libraries or Java library are compatible.
> It isn't fast enough for serverless If that was entirely true, e.g. https://github.com/pedestal/pedestal/tree/master/samples/aws-codestar-lambda wouldn't exist.
Well, I mean, if you are worried about it, its probably not fast enough. The only downside is cold-starts, so if you don't mind users waiting a few seconds once in a while when they hit a cold start. Or if you are okay paying for reserved nodes which you can do on AWS, not sure about google, then it is still viable
If you’re willing to embrace the bumps and partly rough weather, using GraalVM can be incredibly fast, definitely “fast enough for serverless”.
One thing about cloud run - it's not quite like Lambda or Cloud Functions. Your Cloud Run instance is kept alive for longer (basically for as long as it keeps getting requests from clients), and you can configure one instance to handle multiple concurrent requests - so the cold start problem is only a factor you have very small traffic, otherwise it might work better than say, typical FAAS where 1 req = 1 invocation
For faster startup time you could try
java -client -jar ...
https://news.ycombinator.com/item?id=22459518
Hum, I don't know enough about cloud run. But from a quick glance, I don't think Clojure start time would matter
And you could just set it to add an additional instance at some threshold of traffic which you can plan accordingly to how long it takes for the instance to boot
I'd also imagine the container takes probably a good chunk of time to get setup anyways, so the Clojure start time above that won't matter too much
If you need something to start as fast as possible, I would personally just whip it up in rust or go
@U0WL6FA77 Not cloud run, but I recently took a look at running clojure in the Google Cloud function java11 runtime. If you're interested, I've been writing up some notes here: https://github.com/atomist-skills/gcf-java11-clojure
I'll ping the channel when I've got more info about timings. We run a lot of clojurescript Node.js functions on gcf - quite interested in how this java11 runtime performs.
yes, this are also things in my consideration. google cloud functions can be used with java / node.js so I guess with js / cljs / java / clj. I am curious if using cljs and clj is a good idea with cloud functions where time really matter
Well, the gcf functions stay hot for about 5 minutes, and as long as that's true, I'm seeing startup times consistently under 10ms.
But if you don't have sustained throughput, and the invoker shuts down, you see 3-4 seconds.
When you say complexity, are you talking about packaging/monitoring/logging/etc?
Ya, I've been quite pleased with the development experience so far, because it's my normal clojure development flow, with a few "additive" things to test with the google java function invoker before deployment. The deployment I documented above was "mostly" tools cli based. You'll see that I had to directly invoke javac
in one place, but we might be able to get rid of that.
So I see you have to use Java for “boilerplate” https://github.com/atomist-skills/gcf-java11-clojure/blob/master/src/main/java/functions/Main.java and hmm what is happening here. I am not sure.
I was expecting that we could (gen-class)
an HttpFunction
and get rid of that.
FWIW Lein makes a lot of this easier in some aspects (uberjars, compiling java code), but that's a preference. Also, this is based on my experience with AWS Lambda, I never used Cloud Functions.
Right, ya, I think Lein would be perfect for this too. I've been challenging myself to use deps.edn for everything lately 🙂
Although, Lambda works out of the box and doesn't need Java classes, eg this is enough: https://gist.github.com/lukaszkorecki/b59bfab4e5a3a25a47f3933fe01ee662
^ Right! That's awesome! Ya, I wouldn't be satisfied with this gcf method until we can also (gen-class)
the HttpFunction
. It should be as simple as the solution you use for lambda
@U0WL6FA77 depends on which base platform you're more familiar with- I'd pick JVM over JS, because I just don't have enough knowledge to debug node ;-)
@U0143KP47M4 weird, it looks like Lambda-like approach should work. I wish I had the time to try it out. Also, Atomist looks really interesting - gonna check it out
We already do a lot of work with google cloud functions with clojurescript running on Node.js - that's a workflow I know well (can document if anyone is interested). So for me, this was about seeing whether the java11 runtime might be a good addition.
@U0JEFEZH6 I thought this would work https://github.com/atomist-skills/gcf-java11-clojure/blob/master/src/main/clj/atomist/Main.clj but I think I've run into some ClassLoader issues with google's java function invoker
The java11 runtime is pretty new. This might start to change.
Oh, did they have java8 already? Ya, I think I just hadn't realized that.