summaryrefslogtreecommitdiff
path: root/config/initializers/database_config.rb
diff options
context:
space:
mode:
Diffstat (limited to 'config/initializers/database_config.rb')
-rw-r--r--config/initializers/database_config.rb19
1 files changed, 5 insertions, 14 deletions
diff --git a/config/initializers/database_config.rb b/config/initializers/database_config.rb
index cccd4335a7d..a91f67224d7 100644
--- a/config/initializers/database_config.rb
+++ b/config/initializers/database_config.rb
@@ -20,21 +20,12 @@ Gitlab.ee do
end
end
-# Because of the way Ruby on Rails manages database connections, it is
-# important that we have at least as many connections as we have
-# threads. While there is a 'pool' setting in database.yml, it is not
-# very practical because you need to maintain it in tandem with the
-# number of application threads. Because of this we override the number
-# of allowed connections in the database connection pool based on the
-# configured number of application threads.
+# We configure the database connection pool size automatically based on the
+# configured concurrency. We also add some headroom, to make sure we don't run
+# out of connections when more threads besides the 'user-facing' ones are
+# running.
#
-# Gitlab::Runtime.max_threads is the number of "user facing" application
-# threads the process has been configured with. We also have auxiliary
-# threads that use database connections. Because it is not practical to
-# keep an accurate count of the number auxiliary threads as the
-# application evolves over time, we just add a fixed headroom to the
-# number of user-facing threads. It is OK if this number is too large
-# because connections are instantiated lazily.
+# Read more about this in doc/development/database/client_side_connection_pool.md
headroom = (ENV["DB_POOL_HEADROOM"].presence || 10).to_i
calculated_pool_size = Gitlab::Runtime.max_threads + headroom