How to streamline/automate usage-based billing for serverless functions running across multiple cloud envioronments
There are several options to enable usage-based pricing for this use case where you are monetizing the usage of serverless functions in production across various locations, charging per GB-second consumed.
Regardless of the particulars of your usage-based pricing strategy, the most important piece is accurately and completely capturing customer usage. In Amberflo, meters track and aggregate usage. Our SDKs and ingestion API will automatically collect and send usage back to Amberflo for aggregation in realtime.
The simplest strategy for this would be to create one meter to track usage for all functions in production. Use the Duration meter type to send a start and stop event each time a function goes in and out of use, or report the total usage upon completion of a job using a Sum meter. Tag each record with an identifier (event-id dimension) called ‘function_id’ so you can group and analyze usage by function or even bill at different rates for different functions. You can add additional dimensions such as ‘cloud_provider’ to distinguish which cloud platform each function is deployed on and enable more complex by-dimension pricing or analytics.
After configuring the usage data pipeline, create a pricing plan. For this you create a product item that is associated with the meter you’ve created (that is tracking usage for the serverless functions) and select the rate plan. This could be per unit (ie per GB-second), per block, or include more complicated logic such as by dimension, where the different dimension values are used to define rates (ie. charge a different rate for functions running on AWS, Azure, or Google, or get more granular and set rates according to the cloud provider and region).
After the plan is created, assign customers to the activated plan. One option is a streamlined prepaid model where usage is automatically drawn-down against a prepaid balance. Amberflo will keep track of each customer’s prepaid balance, their prepaid transaction history, and show the timeline of prepaid credits consumption. As usage takes place, the invoice amount will be subtracted from the customer’s prepaid balance.
You can create alerts to notify customers and account managers when the prepaid balance is running low, or you can use webhooks to create an automation where the customer’s payment method is automatically charged for additional credits after the balance crosses a certain minimum.
Another option is to implement a pay-as-you-go billing strategy. In this case, there is no prepayment necessary but all usage is tracked and aggregated as it occurs, same as in the prepaid scenario. The invoice is automatically generated and kept up-to-date in realtime. After the billing period ends, the invoice is presented to the customer for payment (billed in arrears). You can automatically charge a payment method on file via Stripe or allow the customer to pay manually.
Regardless of which billing method you choose, Amberflo offers several options to streamline and automate usage-based billing for serverless functions running across various cloud environments.
See related from Invoicing and Payments: