From 61d668c72cebf756c6d4b8814e4728cb0fda0bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Novotn=C3=BD?= Date: Fri, 7 Apr 2023 13:21:47 +0200 Subject: [PATCH] Implemented Francesco Nigro recommendations: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - moved GraphQL server to asynchronous thread Before: Benchmark Mode Cnt Score Error Units ServersThroughputBenchmark.graphQLApiEchoQuery_VertXServer thrpt 5 13350.199 ± 1051.297 ops/s ServersLatencyBenchmark.graphQLApiEchoQuery_VertXServer avgt 5 294.011 ± 8.472 us/op After: Benchmark Mode Cnt Score Error Units ServersThroughputBenchmark.graphQLApiEchoQuery_VertXServer thrpt 5 22699.185 ± 794.541 ops/s ServersLatencyBenchmark.graphQLApiEchoQuery_VertXServer avgt 5 171.575 ± 4.230 us/op --- .../server/vertx/VertXServerRunner.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/one/edee/oss/http_server_evaulation_test/server/vertx/VertXServerRunner.java b/server/src/main/java/one/edee/oss/http_server_evaulation_test/server/vertx/VertXServerRunner.java index 99f3273..2728412 100644 --- a/server/src/main/java/one/edee/oss/http_server_evaulation_test/server/vertx/VertXServerRunner.java +++ b/server/src/main/java/one/edee/oss/http_server_evaulation_test/server/vertx/VertXServerRunner.java @@ -12,18 +12,17 @@ public class VertXServerRunner { public static final int PORT = 8085; - private Vertx vertx; - private GraphQL graphQL; + private final Vertx vertx = Vertx.vertx(); + private final GraphQL graphQL; public VertXServerRunner() { this.graphQL = new GraphQLProvider().getGraphQL(); } public void run() { - vertx = Vertx.vertx(); vertx.deployVerticle(new AbstractVerticle() { @Override - public void start() throws Exception { + public void start() { // Create a Router Router router = Router.router(vertx); @@ -35,7 +34,7 @@ public void start() throws Exception { // reads entire request body for later processing .handler(BodyHandler.create()) // serialization and executing requests against graphql is handled by built-in handler - .handler(GraphQLHandler.create(graphQL)); + .blockingHandler(GraphQLHandler.create(graphQL)); // Create the HTTP server vertx.createHttpServer()