Principle:Apache Spark Master Daemon Management
| Field | Value |
|---|---|
| Domains | Deployment, Distributed_Systems |
| Type | Principle |
| Related | Implementation:Apache_Spark_Start_Master |
Overview
A daemon lifecycle management pattern for starting, monitoring, and stopping the central coordinator process in a master-worker distributed architecture.
Description
In a master-worker architecture, the master daemon acts as the central coordinator responsible for:
- Resource allocation -- tracking available resources across all workers
- Worker registration -- maintaining the set of active workers in the cluster
- Job scheduling -- accepting application submissions and assigning executors
Master daemon management encompasses the full lifecycle:
- Starting the JVM process with configured network bindings
- Configuring host, port, and web UI port for network accessibility
- Writing PID files for lifecycle tracking and process management
- Rotating log files to prevent unbounded disk usage
- Stopping the process gracefully when the cluster is shut down
The master must be started before any workers can register, establishing the coordination endpoint that workers connect to.
Usage
Use when deploying a Spark standalone cluster. The master is always the first daemon started and the last daemon stopped. Typical scenarios include:
- Cluster initialization -- starting the master as the first step in bringing up the cluster
- Master restart -- restarting the master after configuration changes
- Failover -- starting a standby master when the primary fails (with ZooKeeper HA)
Theoretical Basis
The daemon process management follows a structured lifecycle:
configure(host, port, webui_port)
-> spawn_jvm(class, args)
-> write_pid(pid_file)
-> rotate_logs(max_files)
| Lifecycle Phase | Action | Artifact |
|---|---|---|
| Configure | Set host, port, webui-port | Environment variables |
| Spawn | Start JVM with Master class | Running process |
| Track | Write process ID to file | PID file |
| Monitor | Expose Web UI | HTTP endpoint |
| Maintain | Rotate log files | Bounded log directory |