This document outlines a presentation on monetizing and billing for CloudStack. It discusses what resources can be monetized in CloudStack including VMs, networks, storage, and services. It also covers possible billing models and processes including subscription, metering usage, rating usage, invoicing, payments, and dunning. The presentation provides examples of how to map resources to plans, collect usage data from CloudStack, and apply rates to generate invoices.
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
How To Monetise & Bill CloudStack
1. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 1
How To Monetise & Bill CloudStack
A Practical Open Approach
K B Shiv Kumar / CTO@IndiQus
www.apiculus.com
2. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 2
Introduction
● This is a Techno-Functional Talk
● Focuses on CloudStack and Billing
● Laid out in a Questions and Suggestion Format
3. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 3
What All Can We Monetize?
● VM – Disk, CPU, RAM, OS
● VPC – VPC, VR CPU, VR RAM, VR Throughput, Data Transfer
● Networks – Count, Type, Throughput
● VPN Users – Count
● Rules – Firewall Rules, Port Forwarding Rules, Static Routes
● IP – Count
● Containers – Nodes, Count, Size
● Secondary Storage – Data Usage, Period of Storage
● Data Transfer – Account Level
● Services – Managed Services, Professional Services
4. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 4
What Billing Models Are Possible?
● Invoicing Perspective
○ Postpaid
○ Prepaid
● Period Perspective
○ Monthly
○ Quarterly
○ Annually
● Offering Perspective
○ Contractual (mo/qtr/yr)
○ One Time
○ Pay As You Go(PAYG)
● Aggregation Perspective
○ Account Level
○ Resource Level
4
5. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 5
How Do We Offer Services?
● Plans
○ Smallest Atomic Unit of Service
○ Priced (Recurring, One Time, Fixed or
Variable)
○ Has Inclusions Optionally
○ Has Limits
○ Can be of type One Only, Always One,
Many
● Catalogues
○ It’s a Menu Card
○ Can be Multiple – Regional/Customer
Type/Account Specific/Sectoral
○ Price Override is Done Here
○ Selective Offerings are Possible
6. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 6
What Are The Billing Processes?
● Subscribing – Entering into a Contract for a Resource.
● Mediating – Collecting, Normalizing, Adjusting and Aggregating the Usage Data.
● Rating – Rating of that Resource Usage Data.
● Invoicing – Billing Users Periodically on the Charges Incurred Above.
● Apportioning – Processing Payments and/or Advances.
● Dunning – Steps to Recovering Dues.
7. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 7
How Do All These Fit In?
Select Offering
From
Marketplace
Create
Resource In
CloudStack
Identify and
Map The
Applicable Plan
Generate &
Record
Contract
Collect Usage
Mediate and
Adjust Rate and Store Invoice
Receive
Payments
Apportion
Payments
Implement
Dunning
8. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 8
How Do We Subscribe/Contract?
● Plan Mapping
○ Identify Unique Plan(s) and Price
○ Zero-in via Combination (CPU, RAM, disk,
OS, Zone, Region, Account, Bill Type etc.)
○ Plan can be a Monolith(VM) or Smaller
(Compute, Disk, Network, OS)
○ Identify Billing Details (Fixed/Variable;
Monthly/Hourly; OTC/Recurring)
○ Plan Should Map to the Correct Service
Offering, Disk Offering, Template Offering,
Zone, Region etc. in CloudStack. Tags, Tags,
Tags!
○ Use CloudStack Identifiers for above - UUID,
Name, Description, DB ID - All Work Fine
● Contracting/Subscribing
○ Store Plan Rate & Unit – Can be at Plan
Level or Component level
○ Store Date, Period, Un-billed charges and
Line Items (Consider Pro-ration vs Full)
○ Store Contract Type
○ Store Allowances (Consider Period, Unit,
Quantity, Pro-ration)
○ Store the CloudStack Resource Identifier
(UUID, Tags, DB ID - All Work Fine)
○ Store Custom Metadata if Required
○ Use Any Entry Point (CMP, AMQP, Events,
Poll - All Work Fine)
9. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 9
How Do We Collect Data?
● cloud_usage DB and CloudStack Usage API are Your Best Friends!
● It is Recommended to Use Separate Collectors for Separate Types of Resources.
● Collect Periodic Usage for all Rateable Resources(VM, Disk etc.) or Resource Components(CPU,
Network, DT etc.)
● Make sure to Obtain the Resource Identifier as Stored in the Contract. Most Important!
● This can be done via DB Queries or using CloudStack Usage API and Relevant Resource APIs
or a Combination of Both Approaches.
● UUID can be found in almost all CloudStack API Responses while Resource’s DB ID is Present
in usage_id Column of cloud_usage.cloud_usage Table.
10. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 10
Important Settings For Hourly Usage Tracking
● Usage Related Settings In CloudStack
enable.usage.server
usage.sanity.check.interval
usage.execution.timezone
usage.stats.job.exec.time
usage.stats.job.aggregation.range
usage.aggregation.timezone
● For Hourly Usage Set usage.stats.job.aggregation.range as 60.
11. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 11
How Do We Mediate?
● Aggregate at Resource, Period & Granularity Level
○ GROUP BY usage_id, start_date, end_date if using DB. Make sure to join resource tables to obtain
identifier used in the contract.
○ Pass start_date, end_date and type if using the listUsageRecords API.
● Aggregate Resource Usage at the Account Level Where Required
● Map Each Resource ID to the Corresponding Contract
● Obtain the Pricing and Allowances (if any)
● Reduce the Usage by the Allowance Balance
● Provide Final Quantity and UOM for Final Rating
12. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 12
How Do We Rate?
● Apply the Contract Rate on Final UOM
● Better To Rate Till 4 Decimals
● Store in Un-billed Charges Against the Contract
● Aggregate on a Resource or Component Level
12
13. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 13
How Do We Invoice/ShowBack/ChargeBack?
● Needs to Run Every Bill Cycle
● Can be run Everyday
● Aggregate all Un-billed Charges at Contract Level
● Normalize Here for Percentile Billing
● Apply Taxes as Applicable
● Mark Un-billed Charges as Processed
14. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 14
How Do We Implement Dunning?
● Plays Around the Following
Parameters
○ Exposure Limit
○ Unbilled Charges
○ Due Date
○ Payment Amount
○ Outstanding
● Rules may be a Combination of Above
● Actions Can Be
○ Notify – Email, SMS, CMP
○ Curtail Exposure – Set CloudStack
Limits
○ Reversible Block – Disable In
CloudStack
○ Permanent Removal - Delete Account
In CloudStack
15. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 15
Use Case - Hourly Billing Of A VM
User Chooses A VM Config
Ex: 2Core, 4GB, 100GB
Ubuntu 20.04
This Is Mapped To A Plan
Ex: ‘Classic’ VM With Ubuntu
20.04
Plan Contains Service
Offering, Disk Offering and
Template Mapping
Ex: serviceoffering=<uuid>;
templateid=<uuid>
Resource Created In ACS
And UUID/Tag/DB ID
Obtained
Ex: deployVirtualMachine
Identifier(s) Stored In Contract
Ex: cloudstack_resource_uuid
Field
Allowed Usage Stored In The
Contract
Ex(24 Hrs/mo Free)
VM Usage Collected
Perioddically
Ex: Join
cloud_usage.usage_id With
cloud.vm_instance.id
Locate Contract’s
Components Via Identidfiers
Ex: VM’s UUID, Template
UUID, Disk UUID
Absorb Usage Till 24 Hours
Ex: Put Value as 0 Till 1st 24
Hours
Rate Individual Components
Based On Rate
Ex: VM @ USD 0.01/hr; OS
@USD 0.02/hr
Store Un-billed Against
Contract and Period
Ex: VM XYZ 14Nov2022
15:00 to 16:00 0.01
Aggregate All Unbilled Per
Resource
Ex: VM XYZ 1Nov to 30 Nov
USD 696
Apply Percentile If Any Apply Taxes Generate Invoice
16. CloudStack Collaboration Conference 2022
14-16 November 2022 / Sofia, Bulgaria / 16
Thank You!
“Ask no questions and you’ll be told no lies” – Great Expectations, Charles Dickens
K B Shiv Kumar / Chief Technology Officer @IndiQus Technologies
shiv@indiqus.com / shiv@apiculus.io / (91) 9810 527 448