-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dal): Configure minimum connection pool size by env var
Running Novu self-hosted on Mongo Atlas, we quickly hit problems with the 500 connection limit. The DAL service configures the connection pool based on `MONGO_MAX_POOL_SIZE` for the upper limit, and a hard-coded value based on `NODE_ENV` for the lower limit. For both our development and production boxes, we want to run the environment in production to benefit from CORS protection and other optimisations, so the minimum connection pool size is being set to 200. Given that the API, worker and web processes setup a mongo connection (I believe), this equates to 3 x 200 minimum connections and 3 x 500 maximum. This triggers alerts on Atlas and sometimes prevents our Novu service to come up, if say we restart the API process but the workers / web are hogging all the connections. A minimum of 200 also means that we cannot set the `MONGO_MAX_POOL_SIZE` to be less than 200, so to workaround this we're setting our `MONGO_MAX_POOL_SIZE` to be 200 as well to reduce the likelihood of hitting these limits. This issue affects all shared Mongo Atlas instances up to M5, so requiring an M10 instance to run Novu seems overkill. To allow us to have a more modest connection pool for our dev instances, this PR adds a `MONGO_MIN_POOL_SIZE` so that we can adjust this for our setup to keep within the 500 limit. We'd probably have the following settings to keep within 500 connections: MONGO_MIN_POOL_SIZE = 50 MONGO_MAX_POOL_SIZE = 166
- Loading branch information
Showing
14 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters