Skip to content

Commit

Permalink
Add spark.ui.threads to set the max number of the UI threads
Browse files Browse the repository at this point in the history
  • Loading branch information
zsxwing committed Mar 10, 2016
1 parent 3dc9ae2 commit ea99768
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion core/src/main/scala/org/apache/spark/ui/JettyUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import scala.collection.mutable.ArrayBuffer
import scala.language.implicitConversions
import scala.xml.Node

import org.eclipse.jetty.server.{Connector, Request, Server}
import org.eclipse.jetty.server.{AbstractConnector, Connector, Request, Server}
import org.eclipse.jetty.server.handler._
import org.eclipse.jetty.server.nio.SelectChannelConnector
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector
Expand Down Expand Up @@ -270,9 +270,19 @@ private[spark] object JettyUtils extends Logging {

gzipHandlers.foreach(collection.addHandler)
connectors.foreach(_.setHost(hostName))
// As each Acceptor will use one thread, the number of threads should at least be the number
// of acceptors plus 1. (See SPARK-13776)
var minThreads = 1
connectors.collect { case c: AbstractConnector => c }.foreach { c =>
// Limit the max acceptor number to 8 so that we don't waste a lot of threads
c.setAcceptors(Math.min(c.getAcceptors, 8))
minThreads += c.getAcceptors
}
server.setConnectors(connectors.toArray)

val pool = new QueuedThreadPool
pool.setMaxThreads(Math.max(pool.getMaxThreads, minThreads))
pool.setMinThreads(Math.min(pool.getMinThreads, pool.getMaxThreads))
pool.setDaemon(true)
server.setThreadPool(pool)
val errorHandler = new ErrorHandler()
Expand Down

0 comments on commit ea99768

Please sign in to comment.