Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
Use thread multiplier instead
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydmeta committed Nov 16, 2015
1 parent a09e91a commit 896923c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/scala/com/beachape/metascraper/ScraperActor.scala
Expand Up @@ -35,6 +35,8 @@ object ScraperActor {
connectionTimeoutInMs,
requestTimeoutInMs
)

private def coreCount = Runtime.getRuntime.availableProcessors()
}

/**
Expand All @@ -44,7 +46,7 @@ object ScraperActor {
* method
*/
class ScraperActor(
httpExecutorThreads: Int = 10,
threadMultiplier: Int = 3,
maxConnectionsPerHost: Int = 30,
connectionTimeout: Duration = 10.seconds,
requestTimeout: Duration = 15.seconds)
Expand All @@ -58,10 +60,10 @@ class ScraperActor(
val followRedirects = true
val connectionPooling = false

private val executorService = Executors.newFixedThreadPool(httpExecutorThreads)
private val executorService = Executors.newFixedThreadPool(threadMultiplier * ScraperActor.coreCount)
private val config = new AsyncHttpClientConfig.Builder()
.setExecutorService(executorService)
.setIOThreadMultiplier(1)
.setIOThreadMultiplier(threadMultiplier)
.setMaxConnectionsPerHost(maxConnectionsPerHost)
.setAllowPoolingConnections(connectionPooling)
.setAllowPoolingSslConnections(connectionPooling)
Expand Down

0 comments on commit 896923c

Please sign in to comment.