Wednesday, October 7, 2020

Serverless Azure Cosmos DB




     There used to be two ways for Azure Cosmos DB to bill you for the services it provides. Those were Manual Provisioned throughput and Auto scale provisioned throughout.
     
     Provisioned throughput is number of request units available for your applications to use per second. For example, Let's say you picked 400 Request Units. That means your application's budget is 400 request units per second. Depending on your needs, you can scale up or down. You can set this manually and scale up and down manually if you like. That will be the cheapest option which is 100 Request Units for $0.008 per hour. Your other option is the auto scale option, Cosmos DB scales up and down automatically with this option. All you need to tell Cosmos DB is, what the highest number it can scale up to. This option is 50% higher than the first option.

    These are great options, but they can be still be expensive for what you need. Cosmos DB team announced a new way to charge for its services named Serverless. With this method, Cosmos DB charges you when you send a request to your database. When your database is idle waiting for request, Cosmos DB does not charge you. This is like your car stops the engine when you are waiting in the red light, as soon as you press the gas pedal when you see the green light, you start to use the gas and Cosmos DB starts to charge you. This method is in preview and it has some restrictions you need to know.

Type Price
Manual Provisioned throughput 100 RU per second = $0.008 per hour
Auto Scale Provisioned throughput 100 RU per second = $0.012 per hour
Serverless 1 million RU = $0.282

     First thing you need to know about the pricing is 1 million Request Unit is not for per second like other options. That's the total Request Unit you get for $0.28. This gives you 33.333 Request Units per day. Manual Provisioned throughput gives you 8,640,000 Request Units per day. You can save money if your application does not need that much Request Units with serverless model for sure.

    Global Distribution is not available in serveless option, tt can scale up to 5000 Request Units that means if your query will cost more than 5000 Request Unit, serverless cannot run your query. Serverless is available only in SQL API as I write this post. According to Cosmos DB team, all other APIs will have this option too in future. Your application should have light traffice and moderate scaling needs if you want to use Serverless option of Azure Cosmos DB.



     
   

2 comments:

  1. I had created all my containers before serverless exists, is there a chance that I can chance this provision to serverless without doing again the deploy of them?

    ReplyDelete
  2. The breakdown of Cosmos DB's pricing models is enlightening! The shift towards the Serverless charging method aligns well with the fluctuating needs of modern applications, offering a potential cost-saving solution for specific scenarios. The limitations on global distribution and maximum query costs in Serverless are noteworthy factors to consider. TecBrix's dedication to providing Azure Serverless Consulting Services
    can be a valuable resource for businesses navigating these evolving options, ensuring they optimize their choices based on their unique application demands.

    ReplyDelete