should I use Schedulers.io() or Schedulers.compuatation().
You want to calls other services, it's I/O work, so you should not use computation()
. Because it's best to leave computation()
for CPU intensive work only otherwise you won't get good CPU utilization.
can i specify the pool size of computation threads?
No, computation()
is backed by a bounded thread-pool with size equal to the number of available processors. So if you want to spawns 10 threads, you cannot do it.
can i specify the pool size of io threads
If you need to limit the maximum number of simultaneous network calls, use: Scheduler.from(Executors.newFixedThreadPool(10))
It's unnecessary for your use-case, because you only do 10 task at a same time. But it's a good practice, because io()
is unbounded and if you need to schedule hundreds tasks in parallel then each of them will have their own thread and causes context switching overhead.
For more information, see: rxJava Schedulers Use Cases
.