Skip to content

Commit

Permalink
Implemented Francesco Nigro recommendations:
Browse files Browse the repository at this point in the history
- 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
novoj committed Apr 7, 2023
1 parent c888d2e commit 61d668c
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 61d668c

Please sign in to comment.