Serverless computing and Docker are fast turning into seatmates. Where you find one, you’ll find the other.
Case in point: Hyper.sh, a container hosting service that uses custom hypervisor technology to run containers on bare metal, has introduced Func, a Docker-centric spin on serverless computing.
Func allows a user to deploy a function, triggered by a call, via a Docker image. The image needs to be more or less self-contained (“code, dependencies, and data,” according to the documentation) and parked in a public container registry. HTTP requests are sent to a running copy of the container image, and they can be retrieved by a function call ID. Headers in the request are available as environment variables.
Some limitations are placed on how functions are executed. Up to 50MB of everything sent to STDOUT is cached until it’s retrieved, and likewise logs for functions are capped at 50MB and rotated when full. Each STDIN and STDOUT call/response is capped at 1MB. For long batch-processing jobs, this works as long as the results can be broken up across multiple calls and reassembled somewhere.
In many regards, Func is similar to other Docker-inspired projects, such as Functions as a Service. That project uses Unix-standard STDIN and STDOUT to pipe data into and back out of containers when a function is run. Func works much the same way, although it’s offered as a hosted service rather than an open source project. Another serverless project, Fission, uses Kubernetes as its underpinning.
Serverless architecture was a good fit for containers from the beginning, as serverless/lambda-architecture is about short, ephemeral functions invoked on demand, then shut down. Containers provide a useful metaphor for doing so, and they offer a highly standard prepackaging method for the functions.
Hyper.sh offers its services as a commercial product, but some of the containers-on-hypervisor technology it’s created is available as open source. Its hypervisor-agnostic container runtime, for instance, can run containers on either the QEMU or Xen hypervisors, with stronger isolation than a conventional container. Another project, runV, is an OCI-compatible container runtime that also uses hypervisors.