perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.64k stars 1.56k forks source link

First request is always WAY slower than second for the same resource #1068

Closed richarddd closed 5 years ago

richarddd commented 5 years ago

Issue

The first request to ANY resource is always much slower than the second one to that resource. This seems to happen after some idle as well

How to reproduce

With kotlin:

fun main(args: Array<String>) {
    get("/hello") { req, res -> "Hello World" }
}

...or java:

public class HelloWorld {
    public static void main(String[] args) {
        get("/hello", (req, res) -> "Hello World");
    }
}

Get request http://localhost:4567/hello

First request is on my machine around 144 ms Second request is around 10ms

Is this something related to jetty? Could this be configured?

perwendel commented 5 years ago

This is related to Jetty! I've seen issue reports for Jetty on this.