-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ajout de documentation sur le nombre de connexions et de threads max #5118
base: production
Are you sure you want to change the base?
Conversation
@@ -37,6 +37,9 @@ default: &default | |||
# | |||
# | |||
# For GoodJob container, pool size is GOOD_JOB_MAX_THREADS (5) + 3 (1 for LISTEN/NOTIFY, 2 for CRON) | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@francois-ferrandis mon commentaire porte sur la ligne au dessus :
Ce n’est pas ce que je comprends de la doc de goodjob https://github.com/bensheldon/good_job?tab=readme-ov-file#database-connections
2 additional connections that GoodJob uses for utility functionality (e.g. LISTEN/NOTIFY, cron, etc.)
peut-être que ça a évolué depuis le temps où tu avais regardé ?
@victormours Il y a aussi deux autres lignes que j’ai du mal à comprendre
1 connection per execution pool thread. E.g., --queues=mice:2;elephants:1 is 3 threads and thus 3 connections. Pool size defaults to --max-threads.
1 connection per subthread, if your application makes multithreaded database queries (e.g. load_async) within a job.
Je ne comprends pas bien si ça veut dire que ce sont des connexions supplémentaires aux connexions ouvertes dans le pool ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non, ça veut dire qu'il faut dimensionner le pool pour fournir assez de connexions à Goodjob (et c'est bien le cas pour nous vu notre database.yml)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je ne vois aucune modification de cette section du README depuis que j'ai rédigé ce commentaire, donc le plus probable c'est que je me sois trompé à l'époque !
Non, ça veut dire qu'il faut dimensionner le pool pour fournir assez de connexions à Goodjob (et c'est bien le cas pour nous vu notre database.yml)
C'est effectivement ce que cette phrase du README laisse entendre :
The executor process will not crash if the connections pool is exhausted[...]
Et sinon, pour éprouver ma compréhension du sujet, cette liste dans le README exprime "le nombre de connexions potentiellement ouvertes en même temps" et non pas "le nombre de connexion ouvertes en permanence", c'est ça ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, mais en fait le README est incohérent entre la liste
https://github.com/bensheldon/good_job/blob/main/README.md?plain=1#L1145
et la suggestion de config
https://github.com/bensheldon/good_job/blob/main/README.md?plain=1#L1185
pool: <%= 1 + 2 + ENV.fetch("GOOD_JOB_MAX_THREADS", 5).to_i %>
Pourquoi 1 + 2
, à quoi correspond le 1
?
config/puma.rb
Outdated
@@ -32,6 +35,9 @@ | |||
# | |||
# workers ENV.fetch("WEB_CONCURRENCY") { 2 } | |||
|
|||
# NOTE: Cette variable d’env est quand même respectée même quand la ligne au dessus est commentée ! | |||
# Elle est actuellement définie à 2 ou 3 sur les instances de production. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
justement depuis #5120 la variable d'env a été supprimée
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mis à jour merci ! 2f777c3
docs/4-notes-techniques.md
Outdated
|-------------------------------|-----|------| --------------- | ---------------------- | | ||
| scalingo_workers_count | 8 | 2 | - | `scalingo scale` | | ||
| processes_per_worker | 3 | 1 | WEB_CONCURRENCY | config/puma.rb | | ||
| connection_pools_max_sizes | 5 | 8 | GOOD_JOB_MAX_THREADS et RAILS_MAX_THREADS | config/database.yml | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modifié suite à #5120
| connection_pools_max_sizes | 5 | 8 | GOOD_JOB_MAX_THREADS et RAILS_MAX_THREADS | config/database.yml | | |
| connection_pools_max_sizes | 4 | 8 | GOOD_JOB_MAX_THREADS et RAILS_MAX_THREADS | config/database.yml | |
docs/4-notes-techniques.md
Outdated
| processes_per_worker | 3 | 1 | WEB_CONCURRENCY | config/puma.rb | | ||
| connection_pools_max_sizes | 5 | 8 | GOOD_JOB_MAX_THREADS et RAILS_MAX_THREADS | config/database.yml | | ||
| extra_connections_per_process | 0 | 3 | - | doc de GoodJob | | ||
| total_max_connections | 120 | 22 | - | - | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| total_max_connections | 120 | 22 | - | - | | |
| total_max_connections | 96 | 22 | - | - | |
docs/4-notes-techniques.md
Outdated
| extra_connections_per_process | 0 | 3 | - | doc de GoodJob | | ||
| total_max_connections | 120 | 22 | - | - | | ||
|
||
Soit un total de 142 connexions à la base PostgreSQL ouvertes simultanées possibles. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Soit un total de 142 connexions à la base PostgreSQL ouvertes simultanées possibles. | |
Soit un total de 118 connexions à la base PostgreSQL ouvertes simultanées possibles. |
docs/4-notes-techniques.md
Outdated
|-------------------------------|-----|------| | ||
| scalingo_workers_count | 8 | 2 | | ||
| processes_per_worker | 3 | 1 | | ||
| max_threads_count_per_process | 5 | 5 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| max_threads_count_per_process | 5 | 5 | | |
| max_threads_count_per_process | 4 | 5 | |
docs/4-notes-techniques.md
Outdated
| scalingo_workers_count | 8 | 2 | | ||
| processes_per_worker | 3 | 1 | | ||
| max_threads_count_per_process | 5 | 5 | | ||
| total_max_threads | 120 | 10 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| total_max_threads | 120 | 10 | | |
| total_max_threads | 96 | 10 | |
Contexte
Victor est en train d’essayer de réduire le nombre de connexions ouvertes à la base de données pour résoudre les problèmes de mémoire lors des deploys.
Solution
Je rajoute un script qui permet de calculer un instantané des différentes valeurs de config en prod sur RDVS pour générer deux tableaux :
J’ai copié collé ce tableau dans le fichier de doc markdown notes techniques et j’ai rajouté des infos de contexte.
J’ai aussi rajouté des liens in situ vers cette nouvelle doc.