For simplicity of this case I have 1 bucket with several different types of documents and web endpoint in java server based on Undertow. Request is very short-living, it makes 1 query by ID to Couchbase. So it’s 1-1. I do load testing by ApacheBench. Number of concurrent connections varies from 10 to 100-150. That’s quite close to expected production behavior I’m looking to see further down the road.
public Observable<A> findA(String id) {
return this.bucket.async().get(A.id(id), RawJsonDocument.class).map(this::readA);
}
private A readA(RawJsonDocument json) {
return this.jsonMapper.readValue(json.content(), A.class);
}
Later on I’ve added second Couchbase call from a request like this:
Observable<A> aObservable = observable.flatMap(key -> this.repository.findA(request.a()));
Observable<B> bObservable = observable.flatMap(f -> this.repository.findB(request.b()));
Observable.zip(observable, aObservable, bObservable, C::zip)
That actually led to 2 IO threads being utilized!
Couchbase environment is quite standard, I’ve made io
and computation
pools configurable.
@Override
protected CouchbaseEnvironment getEnvironment() {
return DefaultCouchbaseEnvironment.builder()
.ioPoolSize(this.ioPoolSize)
.computationPoolSize(this.computationPoolSize)
.build();
}
I’ve experimented with various pools sizes but that doesn’t change the picture. It’s probably worth to mention that Undertow has its own IO pool for serving connections in async manner.