Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure SQL serveless database cpu billed constantly

So I have a bit of an issue with setting up a new Azure SQL serverless database. enter image description here

I keep getting high CPU billed usage which is costing a fortune, I have resorted to even creating a new DB with a new name in a new region, with a new username and password as well as locking down the firewall. Backups are disabled as well as any auto features. But as soon as the deployment finishes, I start getting billed.

enter image description here

I have run sql profiler and nothing is even touching the DB.

Anyone had this issue before, or know where to start looking?

like image 439
Altus Baard Avatar asked Jul 22 '26 02:07

Altus Baard


2 Answers

The documentation is fairly clear on the conditions required for autopause to start:

Autopausing is triggered if all of the following conditions are true for the duration of the autopause delay:

Number sessions = 0 CPU = 0 for user workload running in the user pool

It also lists some conditions which might prevent autopause - you should double-check you do not have any of the following enabled:

  • Geo-replication (active geo-replication and auto-failover groups).
  • Long-term backup retention (LTR).
  • The sync database used in SQL data sync. Unlike sync databases, hub and member databases support autopausing.
  • DNS aliasing
  • The job database used in Elastic Jobs (preview).

If you find your database is still not pausing, there are a number of ways to track down active connections:

  1. The Azure portal - the portal allows you to drill down into activity just by clicking on the Intelligent Performance hub and Query Performance Insight blade:

Query Performance Insight

Click on query ids (in the red box in my picture) to focus on individual queries.

  1. Connect to the database and run either sp_who2 or sp_whoIsActive (which is now hosted on github) to list active sessions. If you find active sessions you can either disconnect them (eg active SQL Server Management Studio (SSMS) connections, or Azure Data Studio (ADS)) or kill them, as long as you know what you are doing and understand the implications of the kill command.
  2. One slightly unpleasant workaround I found (here) was switching the tier to Standard and switching it back again to serverless. I expect this just has the effect of killing all the active connections in order to switch the tier and does not get to the root cause bit it did work for me.

I would suggest you attempt to diagnose active connections using method 1 or 2 above and report back.

like image 103
wBob Avatar answered Jul 24 '26 21:07

wBob


Note that the "App CPU billed" metric is not quoted in US dollars. It's quoted in vCore seconds.

So in your case, if you're being billed roughly 40 units per minute, at $0.000145 USD per COMPUTE COST/VCORE/SECOND (current rate that I see on the Compute + Storage screen in the portal), then you're being charged $0.0058 per minute, or about $250/mo.

enter image description here

Not sure what your budget is or if you had any confusion around this metric, but it gave me a mild heart attack when I first saw my graph earlier today and mistakenly thought it was quoted in USD.

like image 24
Jon Avatar answered Jul 24 '26 21:07

Jon