Created
June 28, 2019 09:58
-
-
Save andyeff/292b5ce43db47e026a96e064c43f2315 to your computer and use it in GitHub Desktop.
Ansible Tower PSQL tuning
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
# Ansible Tower database settings. | |
''' | |
This is for a Tower instance using a remote postgresql database. | |
Lines from ATOMIC_REQUESTS to PORT are default settings | |
CONN_MAX_AGE and OPTIONS dict are added in | |
This change seemingly allows Tower to re-use its database connections, | |
which can MASSIVELY reduce CPU load if running very verbose playbooks. | |
Currently no real downsides noticed | |
''' | |
DATABASES = { | |
'default': { | |
'ATOMIC_REQUESTS': True, | |
'ENGINE': 'awx.main.db.profiled_pg', | |
'NAME': 'tower', | |
'USER': 'redacted', | |
'PASSWORD': """redacted""", | |
'HOST': 'redacted.postgres.database.azure.com', | |
'PORT': 5432, | |
'CONN_MAX_AGE': 60, | |
'OPTIONS': { | |
'keepalives_idle': 5, | |
'keepalives_interval': 1, | |
'keepalives_count': 5, | |
}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: this file is located at /etc/tower/conf.d/postgres.py on a RHEL 7 Ansible Tower install.
Example performance improvement: Running a playbook that manages Fortigate firewall policies reduced the CPU load on an 8-CPU azure database server from 85-90% (and caused it to sit at high CPU for up to 20 minutes after the playbook finished), to 8% with no post-playbook lag.
(The playbook takes about 5-10 minutes to run and can generate upwards of 100k events)