Apache Hadoop YARN is well known as the general resource-management platform for big-data applications such as MapReduce, Hive / Tez and Spark. It abstracts the complicated cluster resource management and scheduling from higher level applications and enables them to focus solely on their own application specific logic.
In addition to big-data apps, another broad spectrum of workloads we see today are long running services such as HBase, Hive/LLAP and container (e.g. Docker) based services. In the past year, the YARN community has been working hard to build first-class support for long running services on YARN.
YARN Service framework coming in Apache Hadoop 3.1!
This feature, what we call as YARN service framework, has been just merged to trunk back in Nov 2017. In total, it has 108 commits with 33539 lines of code changes. It is expected to become available in the Apache Hadoop 3.1 release. This effort primarily includes the following:
- A core framework (ApplicationMaster) running on YARN serving as a container orchestrator and responsible for all service lifecycle managements.
- A RESTful API-service for users to deploy and manage their services on YARN using a simple JSON spec.
- A YARN DNS server backed by YARN service registry to enable discovering services on YARN with standard DNS lookup.
- Advanced container placement scheduling such as affinity and anti-affinity for each application, container resizing, and node labels.
- Rolling upgrades for containers and the service as a whole.
And YARN Service framework goes hand-in-hand with a few other features in YARN:
- First class support for Docker on YARN.
- A native YARN Timeline Service based on HBase to record lifecycle events and metrics and provide rich analytics APIs for users to fetch/query application details.
- Services UI in YARN UI2.
The bulk of the complexity of managing a Service on YARN is all hidden from the users. Users only deal with a JSON specification to deploy and manage the services running on YARN through CLIs or REST APIs. Below is an example JSON specification for deploying a httpd container on YARN. Users can simply post this JSON spec through REST API or using CLI, and the system will handle the rest – launch and monitor the containers or any other actions required to keep the application running such as auto-restart of a container if it fails. For example:
1. To launch a service, run below command with the supplied JSON
yarn app -launch my-httpd /path/to/httpd.json
2. To get the status of app
yarn app -status my-httpd
3. To flex the number of containers to 3:
yarn app -flex my-httpd -component httpd 3
4. To stop the service:
yarn app -stop my-httpd
5. To restart the stopped service:
yarn app -start my-httpd
Under the hood
The diagram below illustrates the main components involved in a full-fledged YARN cluster to support long running services – under the hood.
A typical workflow is:
- User posts a JSON request that describes the specification of the service such as the container memory size, number of CPU cores, Docker image ID, etc. to the YARN Service REST API. Similarly, user can submit their service creation request using the YARN CLI also.
- RM, after accepting the request, launches an ApplicationMaster (i.e. the container orchestration framework).
- The orchestration framework requests resources from RM adhering to the user’s resource requirements and then, when a container has been allocated, launches the container on NodeManager.
- NodeManager in turn launches the container process (where user code lives) or uses the Docker container runtime to launch the Docker container.
- The orchestration framework monitors containers’ health and readiness and acts upon container failures or unhealthiness. It writes the service lifecycle events and metrics into the YARN Timeline Service (backed by HBase). It also writes the additional service meta info (such as container IP and host) into the YARN service registry backed by a ZooKeeper quorum.
- The Registry DNS server listens on znode creation or deletion in ZooKeeper and creates all sorts of DNS records such as the A record and Service Record to serve DNS queries.
- Each Docker container is given a user-friendly hostname based on information provided in the JSON spec and the YARN configuration. Client can then lookup the container IP by the container hostname using standard DNS lookup.
Which area is YARN service framework good at?
- Hadoop has been in the industry for over 10 years. YARN arrived a little later in Hadoop 2 but also a very mature project and has been endorsed by many companies who run it in large scale in production. Additionally, the YARN Container Orchestration Framework leverages all the existing stable functionalities in Hadoop.
- YARN has been proven to support batch processing workloads like MapReduce and Spark very well. This feature opens the possibility of bringing existing container based services into YARN as well. The result is that users can now use a single cluster to run both batch processing jobs and long running services. This also enables resource sharing between batch jobs and services which could have very different resource utilization patterns. For example, services typically run with high resource utilizations during the day whereas batch jobs are typically run in the night. Therefore, resource sharing can greatly improve overall cluster utilization.
- It supports kerberos security and fits in well with the standard kerberized Hadoop cluster.
- It also supports standard tar packaged apps, in addition to docker containerized apps.
This blog post gives a high level overview on how Apache Hadoop YARN supports container based services. In the next blog post, we’ll talk about more details on how simple it is to run more complicated services such as HIVE LLAP on YARN using this framework. Stay tuned!