Skip to content
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

Rapid reset bench #2

Merged
merged 6 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import pekko.http.scaladsl.settings.{ ClientConnectionSettings, ServerSettings }
import pekko.stream.TLSProtocol.{ SslTlsInbound, SslTlsOutbound }
import pekko.stream.scaladsl.{ BidiFlow, Flow, Keep, Sink, Source }
import pekko.util.ByteString
import com.typesafe.config.ConfigFactory
import org.openjdk.jmh.annotations._

import java.util.concurrent.{ CountDownLatch, TimeUnit }
Expand All @@ -40,6 +41,9 @@ class H2ClientServerBenchmark extends CommonBenchmark with H2RequestResponseBenc

val numRequests = 1000

@Param(Array("1s", "0s"))
var resetFrameThrottleInterval: String = _

@Benchmark
@OperationsPerInvocation(1000) // should be same as numRequest
def benchRequestProcessing(): Unit = {
Expand Down Expand Up @@ -69,7 +73,9 @@ class H2ClientServerBenchmark extends CommonBenchmark with H2RequestResponseBenc
def setup(): Unit = {
initRequestResponse()

system = ActorSystem("PekkoHttpBenchmarkSystem", config)
val resetFrameConfig = ConfigFactory.parseString(
s"pekko.http.server.http2.reset-frame.throttle-interval=$resetFrameThrottleInterval")
system = ActorSystem("PekkoHttpBenchmarkSystem", resetFrameConfig.withFallback(config))
val settings = implicitly[ServerSettings]
val log = system.log
implicit val ec = system.dispatcher
Expand Down
12 changes: 7 additions & 5 deletions http-core/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,13 @@ pekko.http {
# When zero the ping-interval is used, if set the value must be evenly divisible by less than or equal to the ping-interval.
ping-timeout = 0s

# Configure the throttle for Reset Frames (https://github.com/apache/incubator-pekko-http/issues/332)
reset-frame-throttle-cost = 100
reset-frame-throttle-burst = 100
# setting reset-frame-throttle-interval to 0s will disable the throttle
reset-frame-throttle-interval = 1s
reset-frame {
# Configure the throttle for Reset Frames (https://github.com/apache/incubator-pekko-http/issues/332)
throttle-cost = 100
throttle-burst = 100
# setting pekko.http.server.http2.reset-frame.throttle-interval to 0s will disable the throttle
throttle-interval = 1s
}
}

websocket {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,8 @@ private[http] object Http2Blueprint {
private def rapidResetMitigation(
settings: Http2ServerSettings): BidiFlow[FrameEvent, FrameEvent, FrameEvent, FrameEvent, NotUsed] = {
def frameCost(event: FrameEvent): Int = event match {
case _: FrameEvent.DataFrame => 0
case _: FrameEvent.WindowUpdateFrame => 0 // TODO: should we throttle these?
case _ => 1
case _: FrameEvent.RstStreamFrame => 1
case _ => 0
}

BidiFlow.fromFlows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ object Http2ServerSettings extends SettingsCompanion[Http2ServerSettings] {
logFrames = c.getBoolean("log-frames"),
pingInterval = c.getFiniteDuration("ping-interval"),
pingTimeout = c.getFiniteDuration("ping-timeout"),
resetFrameThrottleCost = c.getInt("reset-frame-throttle-cost"),
resetFrameThrottleBurst = c.getInt("reset-frame-throttle-burst"),
resetFrameThrottleInterval = c.getFiniteDuration("reset-frame-throttle-interval"),
resetFrameThrottleCost = c.getInt("reset-frame.throttle-cost"),
resetFrameThrottleBurst = c.getInt("reset-frame.throttle-burst"),
resetFrameThrottleInterval = c.getFiniteDuration("reset-frame.throttle-interval"),
None // no possibility to configure internal settings with config
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
package org.apache.pekko.http.impl.engine.http2

import org.apache.pekko
import org.apache.pekko.http.impl.engine.http2.Http2Protocol.FrameType
import org.apache.pekko.http.impl.engine.http2.framing.FrameRenderer
import org.apache.pekko.util.ByteStringBuilder
import pekko.http.impl.engine.http2.Http2Protocol.FrameType
import pekko.http.impl.engine.http2.framing.FrameRenderer
import pekko.util.ByteStringBuilder

import java.nio.ByteOrder

Expand All @@ -26,7 +26,7 @@ import java.nio.ByteOrder
class Http2ServerDisableResetSpec extends Http2SpecWithMaterializer("""
pekko.http.server.remote-address-header = on
pekko.http.server.http2.log-frames = on
pekko.http.server.http2.reset-frame-throttle-interval = 0s
pekko.http.server.http2.reset-frame.throttle-interval = 0s
""") {
override def failOnSevereMessages: Boolean = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import pekko.http.impl.engine.http2.FrameEvent._
import pekko.http.impl.engine.http2.Http2Protocol.{ ErrorCode, Flags, FrameType, SettingIdentifier }
import pekko.http.impl.engine.server.{ HttpAttributes, ServerTerminator }
import pekko.http.impl.engine.ws.ByteStringSinkProbe
import pekko.http.impl.util.PekkoSpecWithMaterializer
import pekko.http.scaladsl.client.RequestBuilding.Get
import pekko.http.scaladsl.model._
import pekko.http.scaladsl.model.headers.{ CacheDirectives, RawHeader }
Expand Down