Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: calculate civo db costs #694

Merged

Conversation

ShubhamPalriwala
Copy link
Contributor

Problem

Closes #603

Solution

monthlyCost := float64((resourceInGB / 20) * (20 + (resource.Nodes-1)*15))

Changes Made

  • providers/civo/storage/databases.go

How to Test

Try any configuration mentioned in the table in Civo pricing and it should validate. https://www.civo.com/pricing

Screenshots

Tested through ChatGPT :)))
Screenshot_2023-04-04-17-16-20_3000x1920

Notes

Have made the assumption that:

  • the resource.Size will always be added in GigaBytes
  • the resource.Nodes are the total nodes and not just the additional nodes (meaning there will always be 1 node)

Checklist

  • Code follows the contributing guidelines
  • Changes have been thoroughly tested
  • Documentation has been updated, if necessary
  • Any dependencies have been added to the project, if necessary

Reviewers

@jakepage91
@mlabouardy

PS: do not know who to tag here :/ let me know who to for the future

@mlabouardy mlabouardy requested a review from eneskaya April 4, 2023 11:52
@mlabouardy mlabouardy added the civo label Apr 4, 2023
@mlabouardy mlabouardy added this to the v3.0.10 milestone Apr 4, 2023
@eneskaya
Copy link
Contributor

eneskaya commented Apr 4, 2023

Hey @ShubhamPalriwala, I didn't quite get your formula tbh. From our understanding the pricing goes like this:

pricing = (memory size/2)*10 + (cpu cores/2)*20 + (storage size/20)*10 + (number of nodes)*15

Could you explain your approach?

@ShubhamPalriwala
Copy link
Contributor Author

So how I understood it,

  • The cost for a 20GB of an instance with a single node is 20$.
  • Each additional node adds an extra 15$

Now the storage the user chooses (whatever multiple of 20), multiply that to the base value(20) and to the additional nodes(15 per extra)

The amount of RAM/memory stays constant ie 1/10th of the storage space. The same happens for the CPUs as well.

Hence we only need either of Storage and number of nodes to compute the cost

@ShubhamPalriwala
Copy link
Contributor Author

For reference:
Screenshot_2023-04-04-20-53-05_3000x1920

@mlabouardy mlabouardy modified the milestones: v3.0.10, v3.0.11 Apr 4, 2023
@mlabouardy
Copy link
Collaborator

So how I understood it,

  • The cost for a 20GB of an instance with a single node is 20$.
  • Each additional node adds an extra 15$

Now the storage the user chooses (whatever multiple of 20), multiply that to the base value(20) and to the additional nodes(15 per extra)

The amount of RAM/memory stays constant ie 1/10th of the storage space. The same happens for the CPUs as well.

Hence we only need either of Storage and number of nodes to compute the cost

if we took this setup as an example: 40Gb NVME with 2 nodes, by following your formula, the pricing should be 70$/month while in the table its 100$/month

@ShubhamPalriwala
Copy link
Contributor Author

Yeah, it should be 70 only in my opinion as out of 2 nodes (1 is additonal).

The 100 in the table is for 2 additional nodes making it 3 nodes in total.

Let me know if I got wrong at understanding somewhere.

@mlabouardy mlabouardy merged commit 15f7373 into tailwarden:develop Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants