Does it make sense to subscribe async bucket via io scheduler


#1

Hi

I have java code like this to fetch bulk of documents by their keys

private final Bucket bucket;
public Collection<MyDocument> getAndTouch(List<String> keys) {
        return Observable.from(keys).flatMap(
                key -> bucket.async()
                        .getAndTouch(key, 0, RawJsonDocument.class)
                        .map(this::parseJsonDocument))
                .subscribeOn(Schedulers.io()) /*DOES IT MAKE ANY SENCE*/
                .toList().toBlocking().single();
    }

I expect such calls for collections of up to 1oK keys. Since we don’t do computations here but rather IOs I wonder does it make sense to subscribe on IO scheduler. Will it have much impact on performance?
Examples I saw before don’t do this, but I don’t understand why


#2

Hi @ogavrylenko,

No it is not required, the client internally creates io-pool and computation-pool threads either by defaulting to the number of available processors or based on environment configuration.

The io-pool threads are used to make network calls by the underlying netty framework. By specifying to subscribeOn io scheduler, the emissions would switch from client’s io-pool-thread to the Rx-io thread causing additional overhead for context switch and possibly thread creation.