May 17, 2023
Providing complete, accurate, and real-time metering of data storage technology is challenging for a number of reasons. When data is stored to a server or database, resources are consumed continuously from the moment the first byte of data is stored, until the moment when the last byte leaves. Therefore, what is being tracked or metered is not truly the raw usage, but instead the usage rate.
In practice, the “high watermark” approach is used. Instead of calculating the raw usage from the usage rate over the billing period, the max usage rate encountered during the billing period is used and charged. To accurately handle this, the metering service must track and record the max usage rate (the amount of data stored to continue the example from above) ingested over the billing period.
This application is perfect for the Max - Persist meter type in Amberflo. Each time a meter event is received, Amberflo persists that value until a new value is received, or the timeout period ends, at which point the meter value is reset to 0. In each month, the "high watermark" is simply the max value ingested.
In this case, suppose the billing interval goes from the first to the last day of the month. Suppose the timeout period is set to 1 year and the usage begins on 1/1.
A customer uploads a 1 TB file to a database at the start of the first month (on 1/1).In the middle of the third month on 3/15, the customer uploads another file that is half the size (500 GB).
Then, the customer would be billed for 3 months for 1 TB; and the 4th month they would be billed for 500 GB.
This is because 1 TB was persisted as the meter value from 1/1 until the 500 GB file was added on 3/15. 1 TB was the max value seen during the first and second months by default (it was the only value). During the third month, the meter value was set at both 1 TB (from 3/1 thru 3/14) and 500 GB (from 3/15 onwards). Since 1 TB is the high watermark seen during that third month, the customer would be billed for 1 TB. However, at the start of the fourth month the only meter value encountered is 500 GB (persisted from 3/15), so it is the new max for the month of April.