EasyFaaS recommended in this issue is a functional computing service engine with light dependence, strong adaptability, low resource consumption, stateless and high performance.
Features
- Dependence light : EasyFaaS only relies on Linux kernel, does not rely on Docker, Kubernetes and other external services
- Adaptive : EasyFaaS can run on a variety of system environments, including Docker, Kubernetes and bare metal
- Less resource occupation : fewer modules, smaller service system module occupation
- Stateless : Each EasyFaaS Pod itself is stateless and internally autonomous
- High performance : Shorter scheduling links, less overhead, and better performance
For
- Edge computing -Edge
- Internet of Things -IoT
- CICD
- Privatization
- CDN
Fast start
Based on Linux (kernel 4.0+), pre-installed docker provides two ways for developers to get started quickly:
-
- Mode 1: Run in all-in-one mode
- Method 2: Run
with docker-compose
- Method 3: Compile, package and deploy
Method 1: Run in all-in-one mode
Compile
Compile all modules Note: If you are in a linux environment or do not need to compile individual modules, just run the command 1.1
$ make
Cross-compile for other platforms:
$ KUN_BUILD_PLATFORMS="linux/amd64" make
Compile only one module:
$ make WHAT=./pkg/controller
Packing
$ scripts/build-image.sh -h
Usage: scripts/build-image.sh [OPTIONS]
-h --help
-m= --module= module name
-i= --image= image name
-t= --tag= mirror tag
-e= --env= deployment environment (mirroring repository configuration)
Package the all-in-one image, which will contain the controller component, funclet component, and stubs component. Note that the runtime is not currently open source, directly pull the image can be executed:
$ scripts/build-image.sh -m=one -i=easyfaas -t=dev
If you need to publish a packaged image, you need to specify REGISTRY, such as
$REGISTRY=registry.baidubce.com/< your_namespace> / ./scripts/build-image.sh -m=one -i=easyfaas -t=dev
< Upload image
If on the local machine, otherwise need to upload the image
docker push [OPTIONS] NAME[:TAG]
Such as:
docker push registry.baidubce.com/< your_namespace> /< your_image_name> :< your_image_tag>
Start service
export faasPath=/< your_path_prefix> /easyfaas/faas
#runner runtime please download the image directly
docker run -td -e WITHRUNNER=1 -e WITHNODEJS10=1 -e WITHNODEJS12=1 -e WITHPYTHON3=1 --name runner-runtime -v ${faasPath}/runtime:/var/faas/runtime -v ${faasPath}/runner:/var/faas/runner registry.baidubce.com/easyfaas-public/runner-runtime:demo1.0
# Start all-in-one service
docker run -td --privileged -v ${faasPath}/runner:/var/faas/runner -v ${faasPath}/runtime:/var/faas/runtime -v ${faasPath}/data:/var/faas/runner-data --name easyfaas registry.baidubce.com/easyfaas-public/all-in-one:demo1.0
Operation run
After the installation is complete, run the following command to enter the container:
$ docker exec -it easyfaas bash
Method 2: Run the easyfaas service locally with docker-compose
Ensure the normal operation of the local Docker service. Because the underlying of the easyfaas service depends on the underlying linux features such as cgroup/loop devices, it is recommended that the Linux system be preferred.
easyfaas component image
As described in the overall architecture diagram, easyfaas is composed of 4 components, namely controller component, funclet component, runner runtime component, And FUN-Registry, a native code repository built by the stubs module.
You can directly use the public image released by easyfaas. If the local computer cannot access the public network, you can download and store the image file in the tar file from the server that can access the external network environment, and then load the tar file to the server without public network.
< Running easyfaas service
The main configuration is in the./scripts/docker-compose/compose-local/.env file, where
- CONTROLLER_EXPORT_PORT: Service port exposed by the controller component
- REGISTRY_EXPORT_PORT : Service port of mock native function code repository service component
- FUNCTION_DATA_DIR: local function code directory
- easyfaas_REPO : mirror warehouse repo
- CONTROLLER_TAG : controller component image tag, the full image ID is {easyfaas_REPO}/controller:{{easyfaas_REPO}/controller:{CONTROLLER_TAG}
- FUNCLET_TAG : funclet component image tag, full image ID is {easyfaas_REPO}/mini-funclet:{{easyfaas_REPO}/mini-funclet:{CONTROLLER_TAG}
- RUNTIME_TAG: The runner runtime component image tag, the full image ID is {easyfaas_REPO}/runner runtime:{{easyfaas_REPO}/runner runtime:{CONTROLLER_TAG}
- REGISTRY_TAG: Local mock function repository component tag, full image ID {easyfaas_REPO}// fun-registry :{{easyfaas_REPO}// fun-registry :{CONTROLLER_TAG}
# env file configuration example
$ cat ./scripts/docker-compose/compose-local/.env
CONTROLLER_EXPORT_PORT=8899
REGISTRY_EXPORT_PORT=8002
FUNCTION_DATA_DIR=/tmp/funcData
easyfaas_REPO=registry.baidubce.com/easyfaas-public
CONTROLLER_TAG = demo1.0
FUNCLET_TAG = demo1.0
RUNTIME_TAG = demo1.0
REGISTRY_TAG = demo1.0 < / code > < / pre >
Start service
Run the following command to start the service and run docker ps to see if the component is running correctly: The controller component container, funclet component container and FUN-Registry component container are resident containers. Check whether the containers work properly
# Start service
$ cd ./scripts/docker-compose/compose-local/
$ sh app_control.sh start
# Check service
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5bec1b3fd3e4 controller:demo1.0 "./controller --maxproc…" 3 days ago Up 3 days minikun_minikun_1
8b6b1f6d2b1d mini-funclet:demo1.0 "./funclet --logtost…" 3 days ago Up 3 days minikun_funclet_1
5082b7249d28 func-registry:demo1.0 "/stubs --port=8002 …" 3 days ago Up 3 days minikun_registry_1
$Check whether the service is running properly
Core function
Technical architecture
General view
Core Module description
controller
Responsible for traffic scheduling and container pool status management.
- Implement the container scheduling function.
- Supports concurrency at the configuration function level.
- Support container status management, scheduling container status by policy.
- Supports health check and cooldown/reborn can be determined according to runtime status.
funclet
Manage user work containers, including basic container resources and function run resources.
- Container management: implements the init/warmup/reset process for containers.
- Network management: realize functions related to container networks and manage network resources reasonably.
- Mount management: Realize dynamic mount of user containers, and periodically reclaim the mount directory of user containers.
- Process management: properly manage the child processes generated by the user container and handle the child processes that exit unexpectedly.
- Resource capacity management: dynamically adjust the memory resources of the user’s working container.
runner-runtime
runner is responsible for managing the runtime of user functions. Runtime supports the runtime of various development languages. Currently, this component only provides container image
.