-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-13776][WebUI]Limit the max number of acceptors and selectors for Jetty #11615
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -270,9 +270,24 @@ private[spark] object JettyUtils extends Logging { | |
|
||
gzipHandlers.foreach(collection.addHandler) | ||
connectors.foreach(_.setHost(hostName)) | ||
// As each acceptor and each selector will use one thread, the number of threads should at | ||
// least be the number of acceptors and selectors plus 1. (See SPARK-13776) | ||
var minThreads = 1 | ||
connectors.foreach { c => | ||
// Currently we only use "SelectChannelConnector" | ||
val connector = c.asInstanceOf[SelectChannelConnector] | ||
// Limit the max acceptor number to 8 so that we don't waste a lot of threads | ||
connector.setAcceptors(math.min(connector.getAcceptors, 8)) | ||
// The number of selectors always equals to the number of acceptors | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
minThreads += connector.getAcceptors * 2 | ||
} | ||
server.setConnectors(connectors.toArray) | ||
|
||
val pool = new QueuedThreadPool | ||
if (serverName.nonEmpty) { | ||
pool.setName(serverName) | ||
} | ||
pool.setMaxThreads(math.max(pool.getMaxThreads, minThreads)) | ||
pool.setDaemon(true) | ||
server.setThreadPool(pool) | ||
val errorHandler = new ErrorHandler() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,7 +134,7 @@ private[spark] abstract class WebUI( | |
def bind() { | ||
assert(!serverInfo.isDefined, "Attempted to bind %s more than once!".format(className)) | ||
try { | ||
var host = Option(conf.getenv("SPARK_LOCAL_IP")).getOrElse("0.0.0.0") | ||
val host = Option(conf.getenv("SPARK_LOCAL_IP")).getOrElse("0.0.0.0") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK but was this change intentional? rest seems OK There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, never mind. I will remove it. |
||
serverInfo = Some(startJettyServer(host, port, sslOptions, handlers, conf, name)) | ||
logInfo("Bound %s to %s, and started at http://%s:%d".format(className, host, | ||
publicHostName, boundPort)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
collect
or "cast" using pattern matching on type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to crash the app if we add a non-SelectChannelConnector in future. It's better than being silent.