Search code examples
azure-sql-databaseshardingazure-elastic-sharding

Will the shard database increase the number of database in an Azure Elastic pool?


We are preparing to move our SaaS product(single-tenant-per-database model) to Azure SQL with database sharding, from what I learned, a shard is a database and each elastic pool max contains 100 databases. Let's say I have 10 shards in an elastic pool, i.e. 10 shard-databases.

My question is:

  1. These 10 shards(databases) will be counted on the number of databases, so I have 90 databases capacity in the pool?
  2. OR 10 shards only be counted as ONE database and I still have 99 database capacity in the pool?

If it is the case of above option 1, I think there is no reason to use sharding here as we can create a standalone database-per-tenant in the pool without sharding.

Our goal is to save the number of databases in the pool for the free tenants, we thought one database sharded could contain multiple shards for multiple tenants, but finally realized a shard is a database.


Solution

  • Sharding is a technique to distribute large amounts of identically structured data across a number of independent databases.

    • Each shard is counted as a separate database in the elastic pool
    • Therefore, if you have 10 shards in an elastic pool, you will have 10 databases in the pool.
    • The number of databases in the pool is equal to the number of shards in the pool.

    As you mentioned your goal is to save the number of databases in the pool for the free tenants As per Scaling out with Azure SQL Database

    • For Free trial it is cost-effective to use a multi-tenant database for the data

    • When your trial is finished and you choose pay-as-you go, a single-tenant database can be better since it provides better performance.

    • If you have created data during the trial period, use the split-merge tool to move the data from the multi-tenant to the new single-tenant database.