Need to find the queue delay with couchbase java sdk on high traffoc

I have a couple of Api’s that talk to each other that forms a database service .

The 1st api does the authorization and authentication and based on the request uses a web client to talk to a back end api that makes a database call. The back end i am using couchbase . The couchbase is using java sdk calls using query service built in asynchronous non blocking way

We were in process of load testing this architecture we were making calls to a single back end Database api . The back end api completes in 100 ms 99 percentile . The front end api completes in 40 ms 99 percentile of the time .

These things are available from the logs . but the 99 percentile at 20 threads is 500 ms total end to end time( both front end and back end api )

This leads to a conclusion that the requests are getting queued some where . We have a way of finding the queue delay with the Vertx apis but dont know how to do it with Java sdk from couchbase

CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder()
            .connectTimeout(12000) //10000ms = 10s, default is 5s
            .queryServiceConfig(QueryServiceConfig.create(10, 100))
            .requestBufferSize(32768)
            .responseBufferSize(32768)
            .mutationTokensEnabled(true)
            .computationPoolSize(5)
            .build() ; 

bucket = cluster
				.authenticate(config.getString("couchbase.username"),
						new String(Base64.getDecoder().decode(config.getString("couchbase.password"))))
				.openBucket(config.getString("couchbase.bucket"))

private void getN1qlResults(RoutingContext rc, String FinalSql) {
	bucket.async().query(N1qlQuery.simple(FinalSql))
			.retryWhen(RetryBuilder.anyOf(BackpressureException.class)
					.delay(Delay.exponential(TimeUnit.MILLISECONDS, 5000)).max(5).build())
			.flatMap(AsyncN1qlQueryResult::rows).map(row -> {
				return row.value().toString();
			}).timeout(10, TimeUnit.SECONDS).subscribe(new Subscriber<String>() {

				JsonArray jarray = new JsonArray();

				public void onCompleted() {
					// Extra logger for debug
					LOGGER.info("Sending final response ");
					if (jarray.size() > 0) {
						Response = QueryResponse.sendResponse(rc, 200, "SUCCESS", "Results Found", jarray);
						Response.setHandler(resu -> {
							if (resu.succeeded()) {
								Response.complete();
							} else {
								Response.fail(resu.cause());
							}
						});

					} else {
						Response = QueryResponse.sendResponse(rc, 404, "FAILURE",
								"No results found for SQL Statement :", FinalSql.toString());
						Response.setHandler(resu -> {
							if (resu.succeeded()) {
								Response.complete();
							} else {
								Response.fail(resu.cause());
							}
						});

					}

				}

				@Override
				public void onError(Throwable exp) {

					LOGGER.info("Error retriving the query docs :" + exp.toString());

					Response = QueryResponse.sendResponse(rc, 500, "FAILURE",
							"Some thing went wrong exequting the request: ",
							new JsonArray().add(new JsonObject().put("request", FinalSql.toString()))
									.add(new JsonObject().put("response", exp)));
					Response.setHandler(resu -> {
						if (resu.succeeded()) {
							Response.complete();
						} else {
							Response.fail(resu.cause());
						}
					});

				}

				@Override
				public void onNext(String NextJson) {
					// Add the Json objects from couchbase into the Json Array
					LOGGER.info("received a doc: ");
					JsonObject jobj = new JsonObject(NextJson);
					jarray.add(jobj);

				}

			});
}