From 264bab67001cd7974237e4730af92af0b905668f Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Sun, 29 Nov 2020 14:15:34 +0100 Subject: [PATCH] trying to fight the UI unavaiability this path addresses a possible issue with too many open connections to remote peers --- source/net/yacy/http/Jetty9HttpServerImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/net/yacy/http/Jetty9HttpServerImpl.java b/source/net/yacy/http/Jetty9HttpServerImpl.java index 1bcdcfb4d..7b1c1b107 100644 --- a/source/net/yacy/http/Jetty9HttpServerImpl.java +++ b/source/net/yacy/http/Jetty9HttpServerImpl.java @@ -51,6 +51,7 @@ import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.InetAccessHandler; import org.eclipse.jetty.server.handler.gzip.GzipHandler; import org.eclipse.jetty.servlet.ServletHolder; +import org.eclipse.jetty.util.ProcessorUtils; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.webapp.WebAppContext; @@ -75,10 +76,15 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer { Switchboard sb = Switchboard.getSwitchboard(); server = new Server(); - ServerConnector connector = new ServerConnector(server); + + int cores = ProcessorUtils.availableProcessors(); + int acceptors = Math.max(1, Math.min(4, cores/2)); // original: Math.max(1, Math.min(4,cores/8)); + HttpConnectionFactory hcf = new HttpConnectionFactory(); + ServerConnector connector = new ServerConnector(server, null, null, null, acceptors, -1, hcf); connector.setPort(port); connector.setName("httpd:"+Integer.toString(port)); connector.setIdleTimeout(9000); // timout in ms when no bytes send / received + connector.setAcceptQueueSize(128); server.addConnector(connector); // add ssl/https connector