Understanding YARN and Container Lifecycle
YARN (Yet Another Resource Negotiator) is the resource management and job scheduling system in Hadoop. It is responsible for managing the cluster resources and allocating them to various applications running on the Hadoop cluster.
In YARN, the basic unit of computation is a "container". A container represents a collection of physical resources, such as memory, CPU, and disk, allocated for a specific application to run. The lifecycle of a container in YARN can be divided into the following stages:
YARN Container Lifecycle
-
Application Submission: When a user submits an application to the YARN cluster, the Application Master (AM) is responsible for negotiating resources with the Resource Manager (RM) and requesting containers to execute the application's tasks.
-
Container Allocation: The Resource Manager (RM) receives the container request from the Application Master (AM) and allocates the requested resources to the application. The RM then notifies the Node Manager (NM) on the appropriate node to launch the container.
-
Container Launching: The Node Manager (NM) on the target node receives the container launch request from the RM and starts the container. The NM is responsible for monitoring the container's resource usage and ensuring that it does not exceed the allocated resources.
-
Container Execution: The container runs the application's tasks, utilizing the allocated resources. The Application Master (AM) is responsible for monitoring the progress of the tasks and managing the container's lifecycle.
-
Container Completion: When the container's tasks are completed, the container is terminated, and the resources are released back to the YARN cluster for use by other applications.
graph TD
A[Application Submission] --> B[Container Allocation]
B --> C[Container Launching]
C --> D[Container Execution]
D --> E[Container Completion]
Understanding the YARN container lifecycle is crucial for troubleshooting and resolving issues related to "container killed by YARN" errors, which can occur when a container is terminated prematurely by the YARN resource management system.