Thread pools on the JVM should usually be divided into the following three categories:
- CPU-bound
- Blocking IO
- Non-blocking IO polling
Each of these categories has a different optimal configuration and usage pattern.
| object FinchServer { | |
| def serve[F[_]](s: Service[Request, Response], config: RestServerConfig)(implicit F: Concurrent[F]): F[Unit] = { | |
| F.cancelable { _ => | |
| val twitterServer: TwitterServer = new TwitterServer() { | |
| val server: ListeningServer = Http.server | |
| .withMaxRequestSize(config.maxRequestSize.megabytes) | |
| .withAdmissionControl | |
| .concurrencyLimit( | |
| maxConcurrentRequests = config.maxConcurrentRequests, | |
| maxWaiters = config.maxWaiters |