Skip to content

Poor performance or my mistake? #3540

@jtlapp

Description

@jtlapp

I'm getting ready to do some concurrency benchmarks, but I don't think I have my Jooby app set up properly, because Spring Boot is vastly outperforming it on a REST API that does nothing but sleep for one second. In my little test run, I'm able to get 8 requests/second out of Jooby (with lots of timeouts) and 170 requests/second out of Spring (with no timeouts).

Here is my Jooby app:

package com.jtlapp.jvmvsjs;

import io.jooby.Jooby;
import io.jooby.StatusCode;
import io.jooby.netty.NettyServer;

public class JoobyNoMVCJdbcApp extends Jooby {

  {
    install(new NettyServer());

    get("/api/sleep/{millis}", ctx -> {
      int millis = ctx.path("millis").intValue();
      try {
        Thread.sleep(millis);
        return ctx.send(StatusCode.OK);
      } catch (InterruptedException e) {
        return ctx.send(StatusCode.SERVER_ERROR);
      }
    });
  }

  public static void main(final String[] args) {
    runApp(args, JoobyNoMVCJdbcApp::new);
  }
}

Here is the relevant portion of my Spring app:

package com.jtlapp.jvmvsjs.controllers;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class ApiController {

    @GetMapping("/sleep/{millis}")
    public ResponseEntity<Void> sleep(@PathVariable(name = "millis") int millis) {
        try {
            Thread.sleep(millis);
            return ResponseEntity.ok().build();
        } catch (InterruptedException e) {
            return ResponseEntity
                    .status(HttpStatus.INTERNAL_SERVER_ERROR)
                    .build();
        }
    }
}

If you need more details, they are in this repo, deploying Jooby via the jooby-nomvc-jdbc chart and Spring via the spring-jdbc-kernel chart.

What am I doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions