Closed spencewenski closed 2 months ago
Looks good to me. I didn't impl this prior because I figured someone could copy the run run()
method and change the number of concurrent workers. That said, this is really clean and I like it.
This is the one area I feel comfortable massaging the API until it's right so long as no functionality is removed once added.
Released as v0.10.3
Thanks again, @spencewenski ❤️
Problem
If an app's workload is largely IO bound (querying a DB, making web requests and waiting for responses, etc), its workers will spend a large percentage of time idle
await
ing for futures to complete. This in turn means the CPU will sit idle a large percentage of the time (if nothing else is running on the host), resulting in under-utilizing available CPU resources.Solution
Allow apps to configure the number of tokio tasks that are spawned for workers. This will allow the app to configure the processor to use CPU resources more efficiently. For backwards compatiblity and in order to provide a sane/safe default, the default number of workers if not provided is the host's CPU count.