Spark History Server
| Also known as | History server, port 18080 |
|---|---|
| Field | Monitoring and debugging |
| Key parts | Event log directory, FsHistoryProvider, local KV store, cleaner, REST API at /api/v1 |
| Open source implementations | Apache Spark |
| Related | Spark UI, Spark event log, Spark listener |
The Spark History Server is a long-running Apache Spark service that reads the event logs of applications and rebuilds their Spark UI, so that jobs, stages, SQL queries and executors can be inspected after an application has finished. It is started with ./sbin/start-history-server.sh and serves a web interface at http://<server-url>:18080 by default, listing completed and incomplete applications.[1] The live Spark UI on port 4040 disappears when the driver exits; the History Server is how finished applications are debugged.
How does the Spark History Server work?
The History Server and the applications share a directory. Each application writes its event log there, and the server reads it:[1]
# On the applications
spark.eventLog.enabled true
spark.eventLog.dir hdfs://namenode/shared/spark-logs
# On the History Server
spark.history.fs.logDirectory hdfs://namenode/shared/spark-logs
Event logging is off by default (spark.eventLog.enabled, default false), and both spark.eventLog.dir and spark.history.fs.logDirectory default to /tmp/spark-events.[2][3][4] spark.history.fs.logDirectory accepts a comma-separated list of directories, so one server can watch several locations.[3]
The default provider, org.apache.spark.deploy.history.FsHistoryProvider (spark.history.provider), scans the directory every spark.history.fs.update.interval (default 10s) for new or changed logs.[3] When a user opens an application, the server replays its event log through the same status listeners that build the live UI, and caches the result. spark.history.retainedApplications (default 50) sets how many applications' UI data stay in the cache; others are loaded from disk again when opened.[3]
Reading finished applications
The History Server shows the same tabs as the live Spark UI: Jobs, Stages, Storage, Environment, Executors and SQL. The same data is available from the REST API, at http://<server-url>:18080/api/v1, which is useful for scripts that compare runs.[1]
The Spark documentation lists several behaviours that surprise new users:[1]
- An application with several attempts shows its failed attempts, as well as the ongoing or final successful attempt.
- Incomplete (running) applications are refreshed only at each update interval. The documentation recommends viewing a running application in its own live UI.
- An application that exits without registering as complete, for example after a crash, stays listed as incomplete. Stopping the session explicitly (
spark.stop()) marks it complete.
Retention: how long are event logs kept?
The History Server does not delete event logs unless its cleaner is turned on. The cleaner settings at Spark 4.3.0 are:[3][1]
| Setting | Default | Meaning |
|---|---|---|
spark.history.fs.cleaner.enabled |
false | Turns on periodic deletion of event logs. |
spark.history.fs.cleaner.interval |
1d | How often the cleaner runs. |
spark.history.fs.cleaner.maxAge |
7d | Logs older than this are deleted. |
spark.history.fs.cleaner.maxNum |
Int.MaxValue | If there are more logs than this, the oldest completed attempts are deleted. |
A log is deleted if either condition holds. When several log directories are configured, one cleaner cycle covers all of them.[1]
For long-running applications, the History Server can also compact rolled event logs. Setting spark.history.fs.eventLog.rolling.maxFilesToRetain (default: all files kept) makes the server rewrite older rolled files into one compact file, dropping events for finished jobs, terminated executors and finished SQL executions. The documentation calls compaction lossy, notes that it may not run if little space would be saved, and asks users to use it with caution.[1] See Spark event log for rolling.
Running a History Server at scale
Replaying a large event log takes time and memory. Several settings help:[3][1]
spark.history.store.path(no default) stores application data on local disk instead of in memory, and reuses it after a restart.spark.history.store.maxDiskUsage(default 10g) caps that disk.spark.history.store.hybridStore.enabled(default false, since 3.1.0) first parses logs into memory and then moves the result to disk, limited byspark.history.store.hybridStore.maxMemoryUsage(default 2g).spark.history.fs.numReplayThreadssets how many threads replay logs; its default is a quarter of the available cores.SPARK_DAEMON_MEMORYsets the server's memory (default 1g).
Access control uses spark.history.ui.acls.enable and the admin ACL settings, and Kerberos is supported with spark.history.kerberos.enabled.[3]
See also
References
- ↑ 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 Monitoring and Instrumentation (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ config/package.scala (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ 3.0 3.1 3.2 3.3 3.4 3.5 3.6 config/History.scala (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.
- ↑ EventLoggingListener.scala (v4.3.0). Apache Software Foundation.Retrieved 2026-11-23.