Discover how AWS, the famous cloud computing platform, makes hardware more affordable with its flexible on-demand pricing based on many dimensions.
What's in it for you?
In this article, you will learn how to build an on-demand billing system, with charges calculated according to the region and type of instance selected by the customer.
This template is suitable for companies for which a billable metric can have multiple prices based on its properties, such as cloud computing platforms (see below) and identity verification platforms (e.g. $2 for a bank verification and 3$ for a document verification).
What's the secret sauce?
AWS offers an EC2 on-demand pricing that lets customers pay for compute capacity by the hour. Customers can choose their AWS region and instance type. The same instance may have a different price depending on the region selected.
Here’s how you can replicate this pricing and billing system with Lago.
What do you need?
The first thing to do is to create your company account on Lago Cloud or deploy Lago Open Source on your existing infrastructure. In both cases, you should ask a back-end developer to help you with the setup.
Our documentation includes a step-by-step guide on how to get started with our solution.
Step 1 – How to create metric groups
Lago monitors usage by converting events into billable metrics. AWS’s EC2 pricing includes a single metric based on the total number of hours of use for each instance.
To create the corresponding metric, we use the ‘sum’ aggregation type, which will allow us to record usage and calculate the total number of hours of use.
For this metric, there are two dimensions that will impact the price of the compute capacity:
The AWS region selected by the customer; and
The type of instance (some instances are available in multiple regions, others are only available in specific regions).
Therefore, we should add these two dimensions to our billable metric. This will allow us to group events according to the AWS region and type of instance.
At the end of the billing period, Lago will automatically bill customers for the total number of hours of use for each region and instance.
Step 2 – How to set up an on-demand pricing model
When creating a new plan, the first step is to define the plan model, including billing frequency and subscription fee. AWS’s EC2 plan is ‘pay-as-you-go’, which means that there’s no subscription fee (i.e. customers only pay for what they use).
Our plan only includes the ‘compute’ charge, for which we choose the standard pricing model. As we have defined two dimensions, we can set a specific price for each region/instance combination.
Our plan is ready to be used, now let’s see how Lago handles billing.
Step 3 – How to monitor usage
For each activity that requires computing capacity, AWS records the period of use. This activity is converted into an event that is pushed to Lago.
Lago will group events according to:
The customer account;
The AWS region; and
The type of instance.
For each group, the billing system will then automatically calculate the total number of hours of use and corresponding price. This breakdown will be displayed in the ‘Usage’ tab of the user interface and on the invoice sent to the customer.
An on-demand pricing model that offers flexibility and visibility allows cloud computing platforms like AWS to attract more customers.
With Lago, you can create your own metric dimensions to adapt this template to your products and services.