Ofer Shterling, Daniel Elman
March 27, 2023
To be the true system of record and the source-of-truth for usage and consumption data, a metering system must be capable of accurately tracking usage for all types of events and resources.
As we have written before, Amberflo allows you to meter both instantaneous, discrete events as well as long-lasting events which take place over time. In reality, since long-lasting events describe non-momentary resource consumption at some frequency/scale, the system is tracking the usage rate when metering long-lasting events.
To calculate the true usage from the usage rate, we can imagine the usage rate over time plotted on a graph as shown below. In this case, the usage can be thought of as the area underneath the curve, or the integral, of the usage rate plotted over time. Let’s walk through an example.
Consider a cloud database, where you are metering and billing customers based on data storage. Data storage is a long-lasting resource; if you upload files that take 10GB of memory, then that 10GB is being consumed for as long as the files are saved in the database. In reality, 10GB per unit time is the usage rate after uploading 10GB worth of files. If data is added or removed, then the usage rate will change accordingly. Given this data storage information over some day:
We can plot this usage over time as shown on the chart below. To calculate the total usage over the full day, we find the area under the curve. Ordinarily we would use a definite integral to solve, however since this is a simple example we can use the method of a Riemann sum:
Usage = (10 GB/hr)(6hr) + (7 GB/hr)(6hr) + (12 GB/hr)(6hr) + (12 GB/hr)(5hr) + (10 GB/hr)(1hr)Usage = 60 + 42 + 72 + 60 + 10 = 246 GB
Supporting both long-lasting and instantaneous events out-of-the-box provides a number of key advantages. Many competing platforms only offer the concept of a counter meter, which can only meter discrete events but not usage rate events.
To meter long-lasting events using only the counter meter, you will need to perform some calculations on your own before reporting the event to the metering system. Effectively, you would need to calculate the usage from the usage rate and then report this to the metering system each time there is a change. This approach imposes errors and latency since the usage for a particular rate can’t be calculated until the rate changes, it adds effort and resources demand on your side and at best will only offer an approximation of true usage.
Some of the key benefits of having the concept of long-lasting meters include:
Before diving headfirst into a metering project, it is important to invest the time to really understand the use case – what resources are being tracked and consumed, and what metric is most effective at representing and communicating the usage of each resource? Analyzing usage from this lens will allow you to appreciate the important distinction between an instantaneous or discrete event, and a long-lasting event.
Examples of a discrete event are those that take place and are completed instantly; for example, when an API call is made, a file is sent, a user logs in, and so on. Examples of long-lasting events are perhaps more subtle; bandwidth is consumed at every moment that a connected device is active and connected to a network, so you will actually meter the bandwidth usage rate. Similarly in the cloud database example from above, each time you upload data, you are increasing the usage rate since you are consuming storage in each moment that you have files uploaded to the database.
Hopefully this document provides some background into understanding the importance of metering both instantaneous and long-lasting events, and illustrates how Amberflo’s unique architecture offers a number of advantages based on this capability.