Akka Websocket 4x slower when updating Scala 2.12 to 2.13

Hello,
Akka version is 2.5.26 and Play is 2.7.3.
Following is a sample server that demonstrates an issue I’m having:

object Test extends App{

  val app = GuiceApplicationBuilder(configuration = Configuration.apply("play.server.websocket.frame.maxLength" -> 11 * 1024 * 1024)).build

  val routes: PartialFunction[RequestHeader, Handler] = {
    case GET(p"/test_pressure") => WebSocket.accept[play.api.http.websocket.Message, play.api.http.websocket.Message] { request => {
      Flow.fromSinkAndSource(Sink.foreach(in => {
        println("got message")
      }), Source.maybe)
    }
    }
  }

  val config = ServerConfig(
    rootDir = new File(""),
    port = Some(0),
    sslPort = None,
    address = "127.0.0.1",
    mode = Mode.Test,
    properties = System.getProperties,
    configuration = app.configuration
  )

  val server = AkkaHttpServer.fromRouterWithComponents(config)(_ => routes)

  println("port = " + server.httpPort.get)
}

A client connects to this server and sends 100 websocket messages, 10MB in size each (1GB total) as fast as possible.

I’m starting the server in 2 configurations:

  1. scalaVersion := “2.12.10” in build.sbt
  2. scalaVersion := “2.13.1” in build.sbt

This is the only difference between the two tests.

The issue is that in Scala 2.12.10 the test takes 6 seconds to complete, whereas in Scala 2.13.1 the same test takes 22 seconds.
Any idea what would make such a huge difference?

Issue: https://github.com/akka/akka-http/issues/2788

1 Like