I have recently watched the talk Fine-Grained Sandboxing with V8 Isolates, by Cloudflare Workers’ chief architect.
The TL;DR is that V8 (the JS engine) can create sandboxed environments where users’ code can be executed. These execution environments are called V8 Isolates.
The interesting bit is that you can create a single process, a single V8 instance, and potentially thousands of isolates, thus allowing to run serverless functions with an extremely lower latency compared to other serverless platform that need to create both a container and a process where the container runs.
Since these isolates are a feature of the JS engine, I was wondering if there is a similar thing for the JVM. I think it would be really powerful to pay the price of starting the JVM only once for multiple tenants.
I came across 2 resources:
- the java.lang.isolate package, that describes the Isolate API;
- the article Isolates and Compressed References: More Flexible and Efficient Memory Management via GraalVM, that gives a good high-level overview of these isolates and discuss how they are implemented in GraalVM.
Here is a quote from the aforementioned article:
A GraalVM isolate is a disjoint heap that allows multiple tasks in the same VM instance to run independently. In a traditional Java application server, all of the tasks share the same memory heap, and if one task uses a lot of memory it can trigger garbage collection (GC), slowing down the other tasks sharing that heap. Isolates are provably disjoint, so each isolate can be garbage-collected independently (or just destroyed before any GC is needed).
As far as I understand, in the Java ecosystem only GraalVM implemented the Isolate API described in the java.lang.isolate package. Are you aware of other implementations? Could you share your thoughts/opinions on this technology? Thanks!