I use an Azure SQL database with Retool. I recently modified its configuration to be “serverless” meaning when there are no queries to process it will “auto pause” and the cost will get close to zero (charges are for storage only, not compute). However, I was seeing no cost savings. In fact, costs went up because the cost of compute was higher. So, I investigated, and my working theory is that having an active connection with no query traffic crossing is sufficient to keep the database “up” and high charges apply.
ChatGPT sez: “Azure SQL Serverless requires the database to detect complete inactivity, which includes no active connections. Persistent connections, even if idle, are interpreted as activity, preventing the auto-pause mechanism from triggering.”
I also talk to this database through Google Cloud Functions and there I am using the Node driver provided by Microsoft. E.g.: const sql = require('mssql');
and then:
foo = new sql.ConnectionPool(sql_config);
Where sql_config looks like:
const sql_config = {
user: process.env.AZURE_SQL_DATABASE_USERNAME,
password: process.env.AZURE_SQL_DATABASE_USERPWD,
server: process.env.AZURE_SQL_HOST,
database: process.env.AZURE_SQL_DATABASE_NAME,
options: {
encrypt: true
},
pool: {
max: 5, // Maximum number of connections in the pool
min: 0, // Allow the pool to reduce connections to zero when idle
idleTimeoutMillis: 30000 // Close idle connections after 30 seconds
}
};
In this code I have explicit control over the creation of a connection pool via max
, min
, etc.
A Retool SQL connection resource has a section called "Connection options" which takes a set of key/value strings. However I don't know how these values might flow into the connection to the SQL server. If I were to define some "key/value" pairs in the Retool resource how would I express these key values? Would the "key" be, for example:
pool.max
pool.min
etc.?
or perhaps this?
key = pool
value = { max: 5, min: 0, idleTimeoutMillis: 30000 }
??