← All challenges

Pay-As-You-Go Pricing

May 2020

business-rulespricing

SaaS vendors typically bill on a pay-as-you-go, tiered-usage basis:

TierUnitsCost
Free Tierfirst 10,000 units/month$0/unit
Tier 1up to 20,000 units/month$0.050/unit
Tier 220,000–50,000 units/month$0.030/unit
Tier 3above 50,000 units/month$0.010/unit

Cloud platforms like AWS require each SaaS vendor to report metered usage per customer every hour. Your pricing decision service is called at the start of each hour with three numbers: total units ever used, units used so far this month, and units used in just the last hour. It must return how many of the last hour’s units fall into Tier 1, Tier 2, and Tier 3 (Free Tier units aren’t billed). A few example rows (all-units / month-units / last-hour-units → Tier 1, Tier 2, Tier 3):

All unitsThis monthLast hourTier 1Tier 2Tier 3
2,0002,000160000
10,20010,20035020000
25,6008,6781,2341,23400
22,00022,00020,50010,0002,0000
32,50032,50010,500010,5000
120,25860,3902,350002,350
120,000120,000120,00010,00030,00070,000

Implement this pricing decision service, test it against the examples above, and report your results.

Send your solutions to DecisionManagementCommunity@gmail.com, or open a pull request to add yours here.

Solutions