Yesterday I did a fun “Serverless Java” session with more than 100 developers working for one of our big customers, and I realize there are 2 big misconceptions on this (thread)⬇️
As much as I like telling things like “serverless is just CGI-BIN in the cloud” or “with serverless you pay for requests, not instances”, those catchy phrases you see on Twitter are mostly wrong
For instance, on Azure:
- functions are multi-threaded, so you can have 20 requests at the same time and still pay the same as 1 request
- you pay for storing your logs and monitoring data, so even with no request you can still pay something
So the pricing model is much more complicated than those catchy phrases.
Not to mention that big customers probably have negotiated discounts, which makes the final price even more complicated.
Then, everybody talks about GraalVM and are totally wrong.
Here’s the usual talk:
- a Docker image with Java and Spring is more than 200Mb in size, and takes several seconds to start up
- a Docker image with a GraalVM native image is 20Mb and have instant cold start up time
Now, the reality with Azure Functions:
- My Spring Boot JAR is 10Mb. Java is already installed (and running!) in my instance
- My GraalVM image is 16Mb, which contains Spring + the JVM, which is incredibly small but BIGGER than the JAR file
Now, to run them, the platform needs to:
- Download those images
- Unzip them
This takes time, and as the GraalVM image is bigger, it is slower.
(Also, on Azure Functions, it doesn’t benefit from a pre-warmed JVM, but that’s another story)
As a result, my cold start up is:
- With the JVM: usually around 6 or 7 seconds
- With GraalVM: usually around 5 or 6 seconds
So GraalVM is faster, but not incredibly faster.
But is it WORTH it?
GraalVM will cost you a lot more engineering and build time, and here we’re talking gaining maybe less than $1 per month.
You’re not even gaining on the RAM price, as we bill per slots of 128Mb and both solutions run under that limit.
Anyway, you can’t win much more than $10 per month, as then you should use out Premium, “always on” plans.
What about green IT? Well, we discussed this over a Teams session with more than 100 remote attendees, I guess avoiding talking about it would have been more energy-efficient
I’ll host another “serverless Java” session at the upcoming @devnexus conference, if that’s interesting to you, please join me there!
And just to clarify about GraalVM:
- The startup time and memory usage are magical. My 16Mb native image is *crazy*
- The serverless platform (to download+unzip the image, and its billing mechanism) makes this much less useful in *this specific* scenario *at this moment*
And some follow up in another thread (as this one is getting long!) https://twitter.com/juliendubois/status/1355131015858159617
You can follow @juliendubois.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.