update backend stuck/stall

This commit is contained in:
Matthias Hochmeister
2026-03-13 08:30:05 +01:00
parent 60488309ca
commit 243da302c7
9 changed files with 199 additions and 156 deletions

View File

@@ -14,7 +14,7 @@ const poolConfig: PoolConfig = {
database: environment.database.name,
user: environment.database.user,
password: environment.database.password,
max: 20, // Maximum number of clients in the pool
max: 30, // Maximum number of clients in the pool
idleTimeoutMillis: 30000, // Close idle clients after 30 seconds
connectionTimeoutMillis: 5000, // Return an error if connection takes longer than 5 seconds
};
@@ -26,6 +26,17 @@ pool.on('error', (err) => {
logger.error('Unexpected error on idle database client', err);
});
// Log pool exhaustion warnings every 60s (only when requests are waiting)
setInterval(() => {
if (pool.waitingCount > 0) {
logger.warn('DB pool pressure detected', {
total: pool.totalCount,
idle: pool.idleCount,
waiting: pool.waitingCount,
});
}
}, 60_000).unref();
// Test database connection
export const testConnection = async (): Promise<boolean> => {
try {

View File

@@ -0,0 +1,11 @@
import axios from 'axios';
import * as http from 'http';
import * as https from 'https';
const httpClient = axios.create({
timeout: 10_000,
httpAgent: new http.Agent({ keepAlive: true, maxSockets: 20 }),
httpsAgent: new https.Agent({ keepAlive: true, maxSockets: 20 }),
});
export default httpClient;