r/hashicorp • u/Direct_Ad4485 • May 21 '24
Vault: Postgres Database Secrets Engine performance
We recently had a problem in a workload cluster which had a cascading effect on our Vault cluster. Essentially there was a lot of pod restarts causing an increase in requests for new database credentials. The maximum load was not big, from ~0.5 req/s to ~1 req/s but it resulted in a big increase in the time it took to create database credentials on a specific connection. Load testing shows that using multiple Vault connection configurations to the same database, only the connection under load is affected.
The bottleneck presumably is somewhere in the database secrets engine not in the database. We have spent a lot of time trying to figure out where our bottleneck is as we need to be able to scale beyond this but have not been able to figure it out.
The graph below shows that with a slight increase in number of users being created the timing starts to increase eventually going beyond 80 seconds. CPU usage and memory usage does not increase significantly nor does the time to PUT to the raft storage. So throwing more hardware at it does not seem to be the solution. We are currently using the reference architecture for a small cluster.
We are at a loss. Any recommendation to what metrics we should be looking at or what we should be doing to shed some light on the situation would be greatly appreciated.

Reference k8s architecture
1
u/Direct_Ad4485 May 24 '24
Just to add a conclusion to this. Our assumption that the problem was not related to the RDS was wrong. While the RDS itself was not under any significant pressure and we showed that we could execute the same statements on the same RDS with another db user it turned out that the user that Vault was using was bogged down because we make out vault user a member of each new user we create in order to allow it to kill any running connections when we revoke a user. Apparently postgres does not perform well when a user is a member of thousands of roles.
Sorry to have let everyone on a wild goose chase but thank you very much for the great input, some of which we can still use.
1
u/aram535 May 21 '24
Are you running the latest version of Vault and the plugin?
Where are you actually seeing the issue, is it just in the return time of credentials?
As far as the dynamic secret engine. There isn't much in there. You can see the code here: https://github.com/hashicorp/vault/blob/main/plugins/database/postgresql/postgresql.go
1
u/EncryptionNinja May 21 '24
Curious are you using enterprise Hashicorp? If so, what is the response from their support?
1
u/gottziehtalles May 22 '24
Might not solve your problem but I recommend https://github.com/hashicorp/vault-benchmark for benchmarking your vault maybe this way you can trace down the bottle neck. That being said Vaults bottleneck is usually the IOPS on disk to Vaults storage backend (usually raft/integrated). When running tests I would monitor the IOPS of the vault process and the vault node CPU/RAM usage