Templates
AWS's on-demand pricing

AWS's on-demand pricing

AWS template

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.

AWS region
Instance
Hourly rate
us-east-1
t3.nano
$0.0052
us-east-1
a1.medium
$0.0255
us-east-1
t4g.small
$0.0168
af-south-1
t3.nano
$0.0068
af-south-1
m6i.xlarge
$0.254
eu-west-1
t3.nano
$0.0057
eu-west-1
a1.medium
$0.0288

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.

Instruction manual

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.

aws-1
How to create a billable metric

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.

Metric groups
How to define dimensions for a billable metric

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).

aws-2
How to create a ‘pay-as-you-go’ plan

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.

aws-3
How to add a charge with multiple dimensions

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.

Event with dimensions
How to create an event with multiple dimensions

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.

Usage details
How usage data is aggregated

Wrap-up

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.

Give it a try, click here to get started!

Two hosting options, same benefits

Whether you choose the cloud version or decide to host the solution yourself, you will benefit from our powerful API and user-friendly interface.

Lago Premium

The optimal solution for teams with control and flexibility.

lago-cloud-version

Lago Open Source

The optimal solution for small projects.

lago-open-source-version