Akka Http JSON serialization is very slow

376 Views Asked by At

I'm measuring 3-4 ms serialization time of simple JSON. Is this the performance to expect from AKKA or is there something that can be done to rectify it?

case class Response(msg: String)
implicit val format = jsonFormat(Response)


def logMagnet()(t: LoggingAdapter): HttpRequest => RouteResult => Unit = {
    request => {
      val startTime = System.currentTimeMillis()
      response => {
        val total = System.currentTimeMillis() - startTime
        logger.info("took $total")
      }
    }
  }

val route = logRequestResult(LoggingMagnet(logMagnet())) {
   val start = System.currentTimeMillis()
   val calculateSomethings = ....
   val duration = System.currentTimeMillis() - start
   val response = Response("took $duration to calculate")
   complete(response)
}

The time between the logged and the response is 3-4 ms consistantly for trivial serializations.

0

There are 0 best solutions below