# This is the main configuration file for the application.
# ~~~~~

# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
play.http.secret.key = "RItx1I:80?W@]8GAtPDuF8Ydd3mXM85p/<7og]Q;uBOdijQAauRDgu73B6`wQP59"

# The application languages
# ~~~~~
play.i18n.langs = [ "en" ]

# Disable default filters
play.filters.enabled = [ ]

play.server.server-header = "Play2"

play.server {
  netty {
    transport = "native"

    option {
      SO_BACKLOG = 256

      child {
        SO_KEEPALIVE = true
        TCP_NODELAY = true

        # The default is 1 since Linux Kernel 3.13
        # You can check via "cat /proc/sys/net/ipv4/tcp_fastopen"
        # However 3 would be better, but we can't change it to that value because we don't have root permission when running the benchmarks
        TCP_FASTOPEN = 1
      }
    }
  }
}

akka {
  actor {
    default-dispatcher {
      fork-join-executor {
        # The TechEmpower benchmark environment uses 4x 10-Core E7-4850 CPUs in the application server
        # That is 40 physical cores / 80 hyperthreaded cores
        # https://www.techempower.com/benchmarks/#section=environment
        parallelism-max = 40
      }
    }
  }
}

# Database configuration
# ~~~~~
slick.dbs.default {
  profile="slick.jdbc.MySQLProfile$"
  db {
    connectionPool=HikariCP
    driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://tfb-database:3306/hello_world"
    user="benchmarkdbuser"
    password="benchmarkdbpass"

    # Number of threads
    # https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing
    # db connections = ((physical_core_count * 2) + effective_spindle_count)
    # The TechEmpower benchmark environment uses 2 x 4-Core E5520 CPUs in the database server
    # That is 8 physical cores
    # https://www.techempower.com/benchmarks/#section=environment
    numThreads=17

    queueSize=2000

    properties {
      characterEncoding=UTF-8
      dontTrackOpenResources=true
      dontCheckOnDuplicateKeyUpdateInSQL=true
      cachePrepStmts=true
      prepStmtCacheSize=500
      prepStmtCacheSqlLimit=2048
      useServerPrepStmts=true
      useLocalSessionState=true
      useLocalTransactionState=true
      rewriteBatchedStatements=true
      cacheResultSetMetadata=true
      cacheServerConfiguration=true
      cacheCallableStmts=true
      callableStmtCacheSize=250
      elideSetAutoCommits=true
      maintainTimeStats=false
      alwaysSendSetIsolation=false
      zeroDateTimeBehavior="convertToNull"
      traceProtocol=false
      jdbcCompliantTruncation=false
      useUnbufferedInput=false
      useReadAheadInput=true
      useSSL=false
    }
  }
}
