Mini-Essay: Efficient tools with Go and unikernels
Last week, I wrote about Unikraft, a unikernel development system. I have been made aware of another one, Nanos. Nanos comes with a build and orchestration tool, OPS. (Both are developed by NanoVMs.)
The unique selling point of unikernels
What's so fascinating about unikernels?
They combine the best of containers and VMs, such as short boot times, small images, or high security.
Moreover, because unikernels run only a single process, the can remove the boundary between kernel space and user space. System calls become faster, and as a result, apps perform much better on a unikernel than on a standard operating system.
Combine this advantage with a feature that unikernel hosting services typically offer: scale to zero. If a unikernel handles no requests, it can shut down completely. Why wasting energy and resources on running an app that does nothing? Just power them down.
Which brings me to internal tools and services.
Tools that “run” but don't run
I daresay many companies pay a lot for VMs idling in the cloud because these VMs run low-traffic, low-demand services, yet the web servers, database systems, and various caches and microservices keep humming regardless of whether there's actual work to do.
Resources and energy wasted for zilch.
Power down unused services
What if apps are designed and written from the start to minimize startup time? Running on a unikernel, they could wake up when a request comes in, process the request, and exit, just like a Function As A Service (FaaS — think “AWS Lambda”).
If an app cannot be designed as a FaaS, it could at least power down after a certain idle time. The first request sent to a powered-down instance would take a bit longer, but subsequent requests while the app is running observe no performance penalty.
And the ideal language is… <drumroll>
Go apps fit extraordinarily well into these scenarios. Go CLI apps can have short boot times as well and therefore don't add much to the (also short) boot times of a unikernel. Go apps need no bytecode interpreter or any kind of application VM in order to run.
Go + unikernels + scale-to-zero look like a dream team.
Why aren't unikernels more popular? (Or is it just me)?