summaryrefslogtreecommitdiffstats
path: root/jdisc_http_service
diff options
context:
space:
mode:
authorgjoranv <gv@oath.com>2018-12-12 12:04:21 +0100
committergjoranv <gv@oath.com>2018-12-12 12:04:21 +0100
commit7cb63ebe0c9eabc23a569044ec6d9fbf3f1a5a13 (patch)
treec2117025ab6240ba3e0cd9d6782db746182f4a6f /jdisc_http_service
parent001c1d6da54d2b052b5b677356be43136c4d8474 (diff)
Revert "Change memory threshold to a percentage of total memory"
This reverts commit 2db810113ffc50b26cae63c034cdf0f33b859c64.
Diffstat (limited to 'jdisc_http_service')
-rw-r--r--jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/ConnectionThrottler.java14
-rw-r--r--jdisc_http_service/src/main/resources/configdefinitions/jdisc.http.connector.def4
-rw-r--r--jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java2
3 files changed, 8 insertions, 12 deletions
diff --git a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/ConnectionThrottler.java b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/ConnectionThrottler.java
index 79a4f93d1df..370ac0aa788 100644
--- a/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/ConnectionThrottler.java
+++ b/jdisc_http_service/src/main/java/com/yahoo/jdisc/http/server/jetty/ConnectionThrottler.java
@@ -40,8 +40,8 @@ class ConnectionThrottler {
if (config.maxConnections() != -1) {
beans.add(new CoordinatedConnectionLimit(config.maxConnections(), idleTimeout));
}
- if (config.maxHeapUtilization() != -1) {
- beans.add(new CoordinatedLowResourcesLimit(config.maxHeapUtilization(), idleTimeout));
+ if (config.maxMemoryUsage() != -1) {
+ beans.add(new CoordinatedLowResourcesLimit(config.maxMemoryUsage(), idleTimeout));
}
}
@@ -70,16 +70,12 @@ class ConnectionThrottler {
}
resetters.forEach(Runnable::run);
}
- private static long toMaxMemoryUsageInBytes(double maxHeapUtilization) {
- return (long) (maxHeapUtilization * Runtime.getRuntime().maxMemory());
- }
private class CoordinatedLowResourcesLimit extends LowResourceMonitor {
-
- CoordinatedLowResourcesLimit(double maxHeapUtilization, Duration idleTimeout) {
+ CoordinatedLowResourcesLimit(int maxMemoryUsageMegaBytes, Duration idleTimeout) {
super(connector.getServer());
super.setMonitoredConnectors(singleton(connector));
- super.setMaxMemory(toMaxMemoryUsageInBytes(maxHeapUtilization));
+ super.setMaxMemory(maxMemoryUsageMegaBytes * 1024 * 1024L);
super.setLowResourcesIdleTimeout((int)idleTimeout.toMillis());
}
@@ -94,8 +90,8 @@ class ConnectionThrottler {
ConnectionThrottler.this.onReset();
}
}
- private class CoordinatedConnectionLimit extends ConnectionLimit {
+ private class CoordinatedConnectionLimit extends ConnectionLimit {
CoordinatedConnectionLimit(int maxConnections, Duration idleTimeout) {
super(maxConnections, connector);
super.setIdleTimeout(idleTimeout.toMillis());
diff --git a/jdisc_http_service/src/main/resources/configdefinitions/jdisc.http.connector.def b/jdisc_http_service/src/main/resources/configdefinitions/jdisc.http.connector.def
index 7967f657aff..ae4e66a236b 100644
--- a/jdisc_http_service/src/main/resources/configdefinitions/jdisc.http.connector.def
+++ b/jdisc_http_service/src/main/resources/configdefinitions/jdisc.http.connector.def
@@ -47,8 +47,8 @@ throttling.enabled bool default=false
# Max number of connections.
throttling.maxConnections int default=-1
-# Max memory utilization as a value between 0 and 1.
-throttling.maxHeapUtilization double default=-1
+# Max memory usage in megabytes (totalMemory - freeMemory).
+throttling.maxMemoryUsage int default=-1
# Max connection accept rate.
throttling.maxAcceptRate int default=-1
diff --git a/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java
index 9622edc5429..479cf514e30 100644
--- a/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java
+++ b/jdisc_http_service/src/test/java/com/yahoo/jdisc/http/server/jetty/HttpServerTest.java
@@ -490,7 +490,7 @@ public class HttpServerTest {
.throttling(new Throttling.Builder()
.enabled(true)
.maxAcceptRate(10)
- .maxHeapUtilization(0.99)
+ .maxMemoryUsage(100*1024)
.maxConnections(10)));
driver.client().get("/status.html")
.expectStatusCode(is(OK));