Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
Estimating Costs (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
crwilcox committed Jun 15, 2020
1 parent 3c5e1a0 commit 211a969
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/_data/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ docs:
url: /getting-started/publishing-temporary-exposure-keys
- title: How to Download Keys
url: /getting-started/downloading-export-batches-keys
- title: Estimating the Cost of Deployment
url: /getting-started/estimating-costs
- title: Design
children:
- title: Server Deployment Options
Expand Down
94 changes: 94 additions & 0 deletions docs/getting-started/estimating-costs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
---
layout: default
---

# Estimating costs of hosting the Exposure Notifications Server

This page explains how you might estimate the cost to deploy servers within the
Exposure Notification Reference implementation. Cost estimates assume the use
of Google Cloud and use
[published pricing rates](https://cloud.google.com/pricing), but similar
calculations could be done for other cloud providers as well as self-hosted
machines. All prices use USD. Also, much of this is simplified. It doesn't
fully account for free-tier exceptions, or tiered pricing. This is meant
to assist in having an approximate idea of cost to operate. This also assumes
the defaults at the time of authoring in [vars.tf](https:/google/exposure-notifications-server/blob/master/terraform/vars.tf).


# Calculating the overall cost
There are a number of variables that need to be figured out to determine cost.
That said, the vast majority of that cost is going to be from the network
egress. The next largest cost is likely for hosting of containers.

Let's assume that we are calculating the cost of operating for an area with:

* A population of 10 Million (10,000,000) people.
* An exposure window of 14 days
* 50% adoption of an exposure notifications system
* 1,250 new cases daily (approxmately .01% new cases per day)

From which we can derive:
* Each new set of keys is 280 bytes (14 days * 20 bytes)
* Each daily batch is 1,250 * 280 bytes = .35 MB
* That file is downloaded 5 Million times per day (1.75 GB/day download) for
a total monthly egress of 52.5 GB.

# Cloud Components and Pricing

## Cloud Run Costs
There are multiple containers needed for a complete deployment:

* Export Cleanup
* Exposure Cleanup
* Export
* Exposure
* Federation In
* Federation Out

The [cost](https://cloud.google.com/run/pricing#pricing_table) for Cloud Run
per container per hour is:
* CPU: $0.00002400 / vCPU-seconds beyond free quota ($2.0736 / day)
* Memory: $0.00000250 / GiB-second beyond free quota ($0.215 / day)

Assuming we run ~4 containers constantly, which given the batch nature of many
may be a high estimate, and assuming we use the currently default terraform
resource limits of 2 CPU and 1G memory per container:

Projected Monthly Cost: 30 * 4 * ((2 * $2.0736) + (1 * $0.215)) = $523.46

## SQL Database Costs
Configured Size in TF: "db-custom-8-30720" with 256GB Disk

Projected Monthly Cost: TBD

## Storage Costs
https://cloud.google.com/storage/pricing

### Data Storage Cost
$0.026 per GB

Projected Monthly Cost: ($0.026 / GB) * (0.00035 GB * 14 days) = $0 (fractional)

### Network Usage Cost
$0.12 per GB (egress)

Projected Monthly Cost: ($0.12 / GB) * (1.75GB/day * 30 days) = $6.30

### Operations Cost
There are two tiers of operations with different billing.

#### Class A
$0.05 per 10,000 operations

Relevant operations from this include `INSERT`, `UPDATE`, and `LIST`. These
will occur as part of batching of exposure keys. These operations will likely
remain under 10,000 for storage as creation of files is batched.

Projected Monthly Cost: $0.05

#### Class B
$0.004 per 10,000 operations

Relevant operations from this include `GET` requests for key batches.

Projected Monthly Cost: .004/10,000 * 60 Million = $24.00

0 comments on commit 211a969

Please sign in to comment.