Overview
Terraform Enterprise supports several operational modes. When you use the External Services mode, storage components such as the PostgreSQL database operate on dedicated servers, independent of the Terraform Enterprise application.
The number of database connections Terraform Enterprise allocates is proportional to the number of CPU cores on its host machine. The connection count can quickly increase to approximately 200. Terraform Enterprise also caches up to 1000 SQL statements for each database connection. This behavior can cause significant spikes in the database's memory usage, even without a corresponding load on the database's CPU.
If the PostgreSQL instance has insufficient memory, its process may crash, causing Terraform Enterprise to become unresponsive. Users may see UI error messages caused by dropped database connections.
Recommendation
To ensure stability, you should allocate memory for the PostgreSQL database instance in accordance with the number of CPU cores on the Terraform Enterprise host machine.
| TFE CPU Cores | Recommended Postgres Memory |
|---|---|
| 16+ | 32 GB+ |
| 8 | 16 GB+ |
| 4 | 8 GB+ |
| 2 | 4 GB+ |
Note: Because Terraform Enterprise caps the maximum number of connections, you do not need to increase the PostgreSQL memory size above 32 GB unless additional memory is required to handle other workloads on the database server.
Additional Information
HashiCorp provides reference architectures for deploying Terraform Enterprise on several platforms: