Browse Source

Merge pull request #4306 from overleaf/jpa-http-sockets-limit

[misc] migrate setting of limit for http/https sockets into entrypoint

GitOrigin-RevId: 2ff568bf89d3175b48246db3645a91428624b31f
Jakob Ackermann 5 years ago
parent
commit
b4777a8cce
2 changed files with 10 additions and 2 deletions
  1. 5 0
      services/web/app.js
  2. 5 2
      services/web/config/settings.defaults.js

+ 5 - 0
services/web/app.js

@@ -23,6 +23,11 @@ if ((Settings.sentry != null ? Settings.sentry.dsn : undefined) != null) {
   logger.initializeErrorReporting(Settings.sentry.dsn)
 }
 
+const http = require('http')
+const https = require('https')
+http.globalAgent.maxSockets = Settings.limits.httpGlobalAgentMaxSockets
+https.globalAgent.maxSockets = Settings.limits.httpsGlobalAgentMaxSockets
+
 metrics.memory.monitor(logger)
 
 const Server = require('./app/src/infrastructure/Server')

+ 5 - 2
services/web/config/settings.defaults.js

@@ -1,8 +1,6 @@
 const { merge } = require('@overleaf/settings/merge')
 
 let defaultFeatures, siteUrl
-const http = require('http')
-http.globalAgent.maxSockets = 300
 
 // Make time interval config easier.
 const seconds = 1000
@@ -74,6 +72,11 @@ const parseTextExtensions = function (extensions) {
 }
 
 module.exports = {
+  limits: {
+    httpGlobalAgentMaxSockets: 300,
+    httpsGlobalAgentMaxSockets: 300,
+  },
+
   allowAnonymousReadAndWriteSharing:
     process.env.SHARELATEX_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING === 'true',