Utilities.swift 793 B

12345678910111213141516171819202122232425
  1. import Vapor
  2. extension Int {
  3. func bounded(to range: ClosedRange<Int>) -> Int {
  4. switch self {
  5. case ...range.lowerBound:
  6. return range.lowerBound
  7. case range.upperBound...:
  8. return range.upperBound
  9. default:
  10. return self
  11. }
  12. }
  13. }
  14. extension System {
  15. // tfb-server (aka, citrine) uses 28 hyper-threaded cores
  16. // postgresql.conf specifies max_connections = 2000
  17. //
  18. // 2000 / (28 * 2) = 35.7 (theoretical max)
  19. //
  20. // https://github.com/TechEmpower/FrameworkBenchmarks/wiki/Project-Information-Environment#citrine-self-hosted
  21. // https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/toolset/databases/postgres/postgresql.conf#L64
  22. static var maxConnectionsPerEventLoop: Int { 32 }
  23. }