play framework slow at first call

have an issue, with playframework just after startup.

I have this simple controller:

class BomberManController @Inject()(cc: ControllerComponents) extends AbstractController(cc) {

  def index() = Action { implicit request: Request[AnyContent] =>

On first call, on prod env, the request take 400ms, at the second request it take 2ms.

I don’t understand why and how optimise that. On my project the request must take less than 300ms.

Did you have any idea?

PlayVersion: 2.6.12

My guess is, it is slow on the first call because the JVM has not warmed up yet. Usually when you first starts up your application, as it starts to process requests, the JVM’s JIT compiler and other optimizations will kick in to make any subsequent requests faster. I don’t have all the details on this off top of my head, but if you Google “JVM warm up”, you will find a lot of detailed information on this topic. That’s why it is sometimes recommended to “simulate” a few “dummy requests” right after your app is deployed to pre-warm it up in preparation to handle actual requests from users.

1 Like

Thank you for your reply