fluent
fluent copied to clipboard
Connection request timed out on heavy traffic
Describe the bug
When running a Postgres instance I sometimes get back:
[ERROR] Connection request timed out. This might indicate a connection deadlock in your application.
I've tried updating the connectionPoolTimeout to 1 min but still get this error. It also usually gets up throwing many of these errors in a row until (maybe?) the connection recovers?
try app.databases.use(
.postgres(url: Environment.get("POSTGRES_URL")!,
connectionPoolTimeout: .minutes(1)
),
as: .psql
)
It has to deal with maybe 40/50 incoming requests at the same time. It seems to usually do fine when only 5/10 requests are arriving.
To Reproduce
Setup postgres instance with the above init and send maybe 40/50 to the vapor server which processes a filter to retrieve some object from the db.
Expected behavior
A clear and concise description of what you expected to happen.
Environment
note: no Package.resolved file was found. framework: not found toolbox: 18.3.0
Not sure why framework is not found.
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/fluent-postgres-driver.git", from: "2.0.0"),
This is running on kubernetes dockerized using the default dockerfile more or less.
@Huddie there have been some major improvements to the underlying PostgresNIO driver - are you still seeing this issue?
I will update and get back to you thanks so much
I'm experiencing the same issue using Fluent + MySQL
I haven't gotten a chance to check so could still be happening for me as well.
This is still happening for postgres, but does not happen for mysql