# Pay-as-you-go (Like EC2)

### Overview

AWS EC2 on-demand pricing can be found on [this page](https://aws.amazon.com/ec2/pricing/on-demand/). The core of EC2 on-demand pricing is a pay-as-you-go plan with a single dimension on running time. The basic structure is billing the running time by hourly price. The critical implementation behind EC2 pricing is that hour is the minimum usage increment, any usage beyond a hour will be rounded up to the entire hour.

### Implement AWS EC2 On-Demand Pricing

EC2 on-demand price can be implemented in Paigo with an offering called `EC2 On-Demand` with one usage dimension attached to the offering. The dimension has following configurations.

* Consumption Unit: Minute
* Consumption Price: $0.096
* Usage Increment: 60
* Rounding: Ceiling
* Aggregate Interval: Hour
* Aggregate Method: Sum

The idea of this configuration is that with a short time interval such as every five minutes, the usage of EC2 instance is sampled, and stored in Paigo as raw usage data. For example, the instance ran for 3 minutes in the past 5 minutes. Therefore, a usage record of `3` is saved to Paigo as the raw usage data. After an hour, Paigo billing aggregation system will kick in and calculate the **sum** (as specified by **Aggregate Method**) of all raw usage data, such as 47 minutes, divide it by **60** minutes chunk (as specified by **Usage Increment**), and round it **up** (as specified by **Rounding**), so that the final billable amount is 1 hour, and the amount due for this hour is $0.096. This algorithm is exactly the algorithm behind Paigo's [Infrastructure-based Method](/usage-metering/infrastructure-based-method.md) to calculate customer's usage and bill automatically.

Note that there is not only one way of implementing EC2 on-demand pricing. Depending on the usage measurement technique, other alternatives including using **Count** as the **Aggregate Method** when the raw usage data measurement is from the CPU Utilization from CloudWatch per minute data. So the aggregation algorithm would count the number of minutes in an hour that the instance CPU is up and running, and finally aggregates to the billable amount, which is still 1 hour and $0.096.

For more information on the algorithm behind billing aggregation of Paigo, read [Product Items](/saas-pricing/pricing-basics/product-items.md#understand-how-billing-aggregation-works) chapter.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.paigo.tech/saas-pricing/model-pricing-structure/pay-as-you-go-like-ec2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
