Developers: Azure SQL DB Serverless can save you money.

If you’ve got a database that doesn’t need to be on all the time, Azure SQL DB Serverless is in public preview now. It makes a lot of sense for those development databases you have to keep around, but don’t really want to pay for.

If your database doesn’t get any queries for 6 hours, it’ll pause billing, and automatically resume again when your queries kick in. Here’s how to set it up in the portal:

The gotchas list looks fair, but a few things stand out:

  • This tier only has 0.5-4 cores (~2-12GB RAM)
  • The minimum auto-pause duration is 6 hours (that’s some pretty doggone slow response time)
  • After auto-pause, the first login attempt will fail
  • Any queries whatsoever reset the clock (including login attempts, which means this won’t really work for databases exposed to the Internet, which you probably shouldn’t be doing without IP restrictions anyway)
  • Not currently available in Australia Central, China East, China North, France South, Germany Central, Germany Northeast, India West, Korea South, South Africa West, UK North, UK South, UK West, and West Central US

This is a total no-brainer for non-public-facing, development-only or archive databases. For hobby apps, the 6-hour time with zero queries doesn’t really make sense: it’s just too long, especially when search engines are going to hit your site at least that often, let alone things like monitoring tools and automated builds.

Update 2019/07/08 – Microsoft just updated the minimum auto-pause duration, dropping it down to 1 hour (from 6). That makes it a much more viable option for cost savings.

Previous Post
The Silent Bug I Find in Most Triggers
Next Post
Book Review: Learn T-SQL Querying by Pedro Lopes and Pam Lahoud

14 Comments. Leave new

  • Brian Boodman
    May 7, 2019 12:19 pm

    I really have to wonder who is in a situation where:
    1) They have random archive databases laying around.
    2) They use those random archive databases rarely enough to justify DB Serverless (as opposed to DB)
    3) They use those random archive databases often enough to justify DB serverless (as opposed to sticking a DB backup somewhere).
    4) Leaving a cheap DB machine turned would represent a non-trivial segment significant portion of their cloud budget.
    5) Sticking the DB on some random developer machine is against policy, and that policy is enforced.

    I’m not saying that nobody wants this, nor am I even saying this feature is worthless. However, I find myself surprised that this feature was higher priority than something else.

    Reply
    • Brian – sometimes, your competitors dictate the features you build. Amazon brought out Aurora Serverless back in 2017, and I think this is one of those features that’s really important to developers.

      It’s certainly important to us, and not just for our dev servers – also for our EU expansion, where I wouldn’t want to dedicate full time servers for a relatively low workload that’s very bursty. Once you build applications with serverless stuff like AWS Lambda or Azure Functions, the most expensive piece of your infrastructure is likely the database server. If your code only runs a few hours a day, why pay for a 24/7 database?

      Reply
    • I recently left a contract position with a public entity that needed this exact kind of solution. As a public entity, they are required by law to keep certain older data available in an easily-accessible format. This data will only be accessed once every 2-3 months for historical purposes and yearly by an auditor. Keeping a backup file was not considered a good solution due to several bad experiences where both long-term local storage and cloud storage files were lost. They were thinking of putting the data into an Azure SQL DB instance, but this would serve their purposes even better as they would not be charged when not needed. Public entities are big on cutting as many costs as possible.

      Reply
  • Nice. Is there a delay between the billing pause and when first query hits? i.e. like Express Idle Timeout ‘feature’

    Reply
  • Brandon M.
    May 8, 2019 6:11 am

    M$ is such a tease with that dropdown box that looks like you can set auto-pause to something less than 6 hours. I’m currently tinkering with a pet project and paying about $20/mo for dog-slow db.t2.micro on AWS. I’d love to have something with a little more horsepower like Azure SQL DB Serverless where I could spin it up, do some work for a couple hours, and then go back to playing Fortnite and have the DB spin down after say, 2 hours of inactivity. Hopefully the Microsoft people fix the glitch and not just update the png cited in your comment.

    Thanks for fighting the good fight, Brent!

    Reply
  • Thanks for sharing this. I’m not sure if will be useful for us right now, but it’s good to know it’s available if we need it. If we do use it, I think it would be for cases when a dev wants their own copy of our database to play with so they don’t affect everyone else. Hopefully the 6 hour minimum will change.

    Reply
  • Oh man, this is a godsend. Can’t wait for MS to extend this to managed instances.

    Reply
    • Gaby – my guess, and this is only a guess, is that they won’t do that quickly. The documentation on this excludes Azure SQL DBs that are involved in geo-replication.

      I do bet that they’ll do it, just not quickly. Aurora Serverless does do it, for example – but it’s a matter of replicating the storage rather than replicating through SQL Server methods, which require the SQL Server to be up and running. There’s no reason they couldn’t have the MDF/LDF files on disk replicated via the storage layer like how Azure SQL DB Hyperscale works, but right now Hyperscale and MI are different product lines.

      Reply
      • Yeah, unfortunately that’s my worry. However, we have a very slow moving developer team (not their fault, i work for a mutual fund company, so by definition, everything is slow).

        As an aside, regarding the storage layer, has it improved, even for Azure? I’ll have to read up on it, but when we tested it in a previous company (think 1000+ DB’s on a SQL enterprise box with traditional failover clustering), bringing up the server for DR testing on the DR site inevitably had 2 to 3 suspect databases. Mind you, this was not in Azure, but with a traditional data center that would replicate from the main site to their DR site. I forget the exact technology but the backup was done at the block level, and me and my fellow DBA put the caveat that as it wasn’t a backup or HA solution from within SQL, we could not guarantee integrity on the DR.

        We did have a fix, which involved bringing up the DR disks to a point in time X minutes back, not last timestamp, and offload those specific DB’s to merge with the full set we’d restore from the last timestamp.

        Reply
        • Gaby – I haven’t tested it since, so your best bet would be doing your own testing. Microsoft raised the published IO limit from 48 MB/sec to 96 MB/sec last time I looked, but, uh…that’s still slower than a $50 USB thumb drive, so I gotta take a pass there.

          Reply
  • Phil Morris
    June 6, 2019 1:51 am

    I love the idea of this but as usual MS seem to have fallen short of what is practical.
    Why can’t we pause manually? Any developer would be happy to stop and start at beginning and end of a dev session (most are building/rebuilding already)

    Reply
  • I process data over the weekends and don’t need a SQL Server that is always on, so the new Serverless tier of Azure SQL Database is attractive. However, the auto-resume feature doesn’t seem to resume without having to write custom retry logic. Are there any combination of Connection String parameters which will make the initial connection wait until the Serverless database has resumed? When the database is in the PAUSED state, initial connections always fail in just under 40 seconds – even when ConnectionTimeout=10000 is provided in the Connection String.

    Reply
    • Damon – the documentation explicitly states that the first connection attempt always fails. You have to have retry logic in your app. (They say the same thing about cluster failovers too, for example.)

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu
{"cart_token":"","hash":"","cart_data":""}