WebUI — Base Web UI

WebUI is the base of the web UIs in Apache Spark:

  • Active Spark applications

  • Spark History Server

  • Spark Standalone cluster manager

  • Spark on Mesos cluster manager

Spark on YARN uses a different web framework for the web UI.

WebUI is used as the parent of WebUITabs.

package org.apache.spark.ui

abstract class WebUI {
  // only required methods that have no implementation
  // the others follow
  def initialize(): Unit
WebUI is a private[spark] contract.
Table 1. (Subset of) WebUI Contract
Method Description


Used in implementations only to let them initialize their web components

initialize does not add anything special to the Scala type hierarchy but a common name to use across WebUIs (that could also be possible without it). In other words, initialize does not participate in any design pattern or a type hierarchy.

WebUI is a Scala abstract class and cannot be created directly, but only as one of the web UIs.

Table 2. WebUIs
WebUI Description


Used in Spark History Server


Used in Spark Standalone cluster manager


Used in Spark on Mesos cluster manager


WebUI of a Spark application


Used in Spark Standalone cluster manager

Once bound to a Jetty HTTP server, WebUI is available at an HTTP port (and is used in the web URL as boundPort).

WebUI is available at a web URL, i.e. http://[publicHostName]:[boundPort]. The publicHostName is…​FIXME and the boundPort is the port that the port the Jetty HTTP Server bound to.

Table 3. WebUI’s Internal Properties (e.g. Registries, Counters and Flags)
Name Description



Used when…​FIXME



Used when…​FIXME


ServletContextHandlers per WebUIPage

Used when…​FIXME


Optional ServerInfo (default: None)

Used when…​FIXME


Host name of the UI

publicHostName is either SPARK_PUBLIC_DNS environment variable or spark.driver.host configuration property.

Defaults to the following if defined (in order):

  1. SPARK_LOCAL_HOSTNAME environment variable

  2. Host name of SPARK_LOCAL_IP environment variable

  3. Utils.findLocalInetAddress

Used exclusively when WebUI is requested for the web URL


Used when…​FIXME

Enable INFO or ERROR logging level for the corresponding loggers of the WebUIs, e.g. org.apache.spark.ui.SparkUI, to see what happens inside.

Add the following line to conf/log4j.properties:


Refer to Logging.

Creating WebUI Instance

WebUI takes the following when created:

  • SecurityManager

  • SSLOptions

  • Port number

  • SparkConf

  • basePath (default: empty)

  • Name (default: empty)

WebUI initializes the internal registries and counters.

WebUI is a Scala abstract class and cannot be created directly, but only as one of the implementations.

Detaching Page And Associated Handlers from UI — detachPage Method

detachPage(page: WebUIPage): Unit


detachPage is used when…​FIXME

Detaching Tab And Associated Pages from UI — detachTab Method

detachTab(tab: WebUITab): Unit


detachTab is used when…​FIXME

Detaching Handler — detachHandler Method

detachHandler(handler: ServletContextHandler): Unit


detachHandler is used when…​FIXME

Detaching Handler At Path — detachHandler Method

detachHandler(path: String): Unit


detachHandler is used when…​FIXME

Attaching Page to UI — attachPage Method

attachPage(page: WebUIPage): Unit

Internally, attachPage creates the path of the WebUIPage that is / (forward slash) followed by the prefix of the page.

attachPage creates a HTTP request handler…​FIXME

attachPage is used when:

Attaching Tab And Associated Pages to UI — attachTab Method

attachTab(tab: WebUITab): Unit

attachTab attaches every WebUIPage of the input WebUITab.

In the end, attachTab adds the input WebUITab to WebUITab tabs.

attachTab is used when…​FIXME

Attaching Static Handler — addStaticHandler Method

addStaticHandler(resourceBase: String, path: String): Unit


addStaticHandler is used when…​FIXME

Attaching Handler to UI — attachHandler Method

attachHandler(handler: ServletContextHandler): Unit

attachHandler simply adds the input Jetty ServletContextHandler to handlers registry and requests the ServerInfo to addHandler (only if the ServerInfo is defined).

attachHandler is used when:

getBasePath Method

getBasePath: String

getBasePath simply returns the base path.

getBasePath is used exclusively when WebUITab is requested for the base path.

Requesting Header Tabs — getTabs Method

getTabs: Seq[WebUITab]

getTabs simply returns the registered tabs.

getTabs is used exclusively when WebUITab is requested for the header tabs.

Requesting Handlers — getHandlers Method

getHandlers: Seq[ServletContextHandler]

getHandlers simply returns the registered handlers.

getHandlers is used when…​FIXME

Binding UI to Jetty HTTP Server on Host — bind Method

bind(): Unit


bind is used when…​FIXME

Stopping UI — stop Method

stop(): Unit


stop is used when…​FIXME