awslabs / amazon-dynamodb-tools

Tools to make effective use of DynamoDB easier.
Apache License 2.0
113 stars 24 forks source link

DynamoDB reserved capacity recommendations does not count days correctly #14

Closed h-minamiohtsu closed 5 months ago

h-minamiohtsu commented 1 year ago

DynamoDB reserved capacity recommendations(reco) checks if the number of days is within the normal monthly range. However, because the days are counted incorrectly, an unnecessary warning message is displayed.

In the example below, a CSV with all the data for February 2023 ( 02/01/23 00:00:00 to 02/28/23 23:00:00 ) is passed, but a warning message is displayed that the number of days is different from the normal month.

$ python3 src/ddbr.py reco --file-name APN1.csv --term 1 --output plain
Intepreting CUR data.
Recommendation will be generated between 02/01/23 00:00:00 and 02/28/23 23:00:00 based on source data.
WARNING: The selected start and end times in file have greater or fewer days than a normal month. As a result, the 'monthly' summaries in the output will not reflect the true monthly cost.
Recommendation will be generated for 1 region(s)
Loading CSV into memory. Please wait.
Generating recommendations.
############################################################
DynamoDB Reserved Capacity Report
These recommendations are based on data from 02/01/23 00:00:00 to 02/28/23 23:00:00. The time span represents 27 days of data. RC term length for the report is 1 year(s)
Please consult your account’s active reserved capacity reservations to determine the amount of capacity to own. The amounts below do not factor in what you already own. Instead, they reflect the amount you should have in your account. Please be aware reservations are not available for rWCUs, the table class S-IA, or for the on-demand capacity mode.
Generated on 03/07/23 21:35:30 with reco version v1.1.1
############################################################
************************************************************
WARNING: Non-standard number of days detected in the report. The fields marked monthly in this report represent the total cost for the selected time period, not the true monthly cost.
Re-run the report with data for only one month to receive accurate monthly cost estimates.
************************************************************
************************************************************
               Tokyo region - ap-northeast-1
************************************************************
Capacity type: Reserved Read Capacity Unit (RCU), Term: 1 year(s)
    Reserved capacity to own (not necessarily buy): 64,200 RCU(s), which is bought as 642 units of 100. Upfront cost: $21,956.40
    Effective monthly rate: $3,236.88, monthly rate after first month: $1,552.55
    Monthly savings over the public rate card: $2,368.61 (42.26%)
    min: 11,135.0 median: 63,007.0 max: 86,645.0 average: 56,209.56 std_dev: 18,761.16 sum: 37,772,821.0
Capacity type: Reserved Write Capacity Unit (WCU), Term: 1 year(s)
    Reserved capacity to own (not necessarily buy): 2,600 WCU(s), which is bought as 26 units of 100. Upfront cost: $4,456.40
    Effective monthly rate: $1,057.84, monthly rate after first month: $715.98
    Monthly savings over the public rate card: $603.55 (36.33%)
    min: 1,662.0 median: 2,519.0 max: 21,694.0 average: 3,331.96 std_dev: 2,849.43 sum: 2,239,074.0
Totals: Effective monthly rate: $4,294.72, monthly rate after first month: $2,268.54, Monthly savings over the public rate card: $2,972.16 (40.9%)
************************************************************
                          Glossary
************************************************************
Reserved capacity to own: How much RC this payer account should own. You must compare the amount to own against your current RC reservations to determine the amount to buy. See report header.
Effective monthly rate: The cost per month, factoring in the upfront RC purchase cost. This is the 'monthly rate after first month' + (upfront cost / months in the RC term). If you already own RC, this amount will be incorrect. This amount is only valid if the time range is one month, otherwise this field is actually the effective cost over the time period selected.
Monthly rate after first month: The price per month if you owned all the recommended RC, not including the upfront cost. This cost includes the usage above the recommended RC plus the RC hourly rate for the recommended number of units. This amount is only valid if the time range is one month, otherwise this field is actually the sum of the cost over the time period selected.
'...savings over the public rate card': The impact of owning this much RC! This is the money you'll save if you own the suggested amount. These prices are calculated using the public pricing and do not include any credits or negotiated discounts.
'XXX units of 100': DynamoDB reserved capacity is bought in batches of 100 units.
############################################################
End of report.
Totals: Effective monthly rate: $4,294.72, Total savings over the public rate card for duration of term: $35,665.88 (40.9%), Total upfront purchase cost: $26,412.80
############################################################
$ python3 src/ddbr.py reco --version
reco v1.1.1
h-minamiohtsu commented 1 year ago

I have opened a PR for the fix. https://github.com/awslabs/amazon-dynamodb-tools/pull/15

Please review the PR.

tebanieo commented 5 months ago

Closing as this issue was resolved on March 7th 2023. PR #15