diff options
author | Haakon Dybdahl <dybdahl@yahoo-inc.com> | 2016-10-27 08:42:24 +0200 |
---|---|---|
committer | Haakon Dybdahl <dybdahl@yahoo-inc.com> | 2016-10-27 08:42:24 +0200 |
commit | 28287edf40152e6510356a3d01651f4222958491 (patch) | |
tree | bb887f2e606c8bbf27e1a71667bc53eacb198028 /vespaclient-container-plugin | |
parent | 94c0eee78ebb755ab867bd7c4be7c020542946f0 (diff) |
Reject requests when overloaded.
Diffstat (limited to 'vespaclient-container-plugin')
-rw-r--r-- | vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java index 113f066edfe..1e8143c2596 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/ClientFeederV3.java @@ -21,6 +21,7 @@ import com.yahoo.yolean.Exceptions; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.net.InetAddress; import java.net.UnknownHostException; import java.time.Duration; @@ -112,9 +113,14 @@ class ClientFeederV3 { threadsAvailableForFeeding.decrementAndGet(); ongoingRequests.incrementAndGet(); try { + FeederSettings feederSettings = new FeederSettings(request); + // We are blocking up too many threads, we can not parse the request and should rather exit early. + if (feederSettings.denyIfBusy && threadsAvailableForFeeding.get() < -10) { + return new ErrorHttpResponse(429, "Gateway overloaded"); + } + InputStream inputStream = StreamReaderV3.unzipStreamIfNeeded(request); final BlockingQueue<OperationStatus> replies = new LinkedBlockingQueue<>(); - FeederSettings feederSettings = new FeederSettings(request); try { feed(feederSettings, inputStream, replies, threadsAvailableForFeeding); synchronized (monitor) { |