ZeroDark.cloud utilizes a pure pay-as-you-go billing model. You only pay for server resources consumed.
The prices you pay are set by AWS. ZeroDark.cloud makes money by adding an additional fee to your bill, which is a percentage of the total.
There are 4 main categories to cover:
- Storage (S3)
- Push Notifications (SNS)
- Compute (Lambda + API Gateway)
We'll walk through each category and:
- link to the official AWS pricing page
- explain the terms used by AWS
- explain how ZeroDark.cloud uses the service
- provide a blueprint for back-of-the-napkin estimates
Real-Time Per-User Monitoring
ZeroDark.cloud tracks all usage in real-time, per-user & per-app. This means you can query the system for any given user's usage for your application, and the system will give you a real-time running total (for the current month) concerning all billable usage. Archived information for previous months is available as well.
Global Price Differences
One quick caveat to point out before we get started. AWS has different prices per geographic region. This is to account for differences in taxes, electricity costs, and other such differences between countries. You may want to take this into consideration when choosing which data centers to support. For example, if your application is going to be storage heavy, you may naturally prefer data centers where storage costs are lower.
All data is stored in S3, and the official prices are here.
This can be broken down into 2 categories
- raw storage
- requests (get, put, list, etc)
For raw storage, the numbers you see on their official pricing page are in "gigabyte months", which means 1 gigabyte stored for an entire month. As a simple example, to help explain the concept:
Imagine the price for a particular region is $0.03 per gigabyte month. And you store exactly 3 gigabytes for 1/3 of a month (and then delete the data). The total cost would be 3 cents (math: 3 gigs * 0.03 * 1/3 = 0.03). Similarly if you store 1/3 gigabytes for an entire month, the cost is 1 cent (math: 1/3 gigs * 0.03 * 1 = 0.01).
ZeroDark.cloud makes use of 3 different tiers
- Standard Infrequent Access
In general, most app data starts life in the standard tier. During that time, it's being actively synced among devices, and updated with changes. The server tracks when each file was last accessed, and can automatically transition it to lower priced tiers. By default, if a file's last access time exceeds 30 days, the file is automatically transitioned to Infrequent Access. If the file isn't accessed for another 60 days, it is then automatically transitioned to Glacier.
In addition to automatic transitioning, the server supports automatic burning. So a file can be flagged with a burn date, after which time the server will automatically delete the file.
For estimating your costs, you'll obviously need to come up with a storage estimate. This is easier for some apps than others. However, a good rule of thumb is to assume the minimum filesize for every file is 1 KiB. This accounts for various things such as permissions & encryption keys.
Also note that AWS uses the common "GB", but they actually mean "GiB". In other words, they're counting in binary, not decimal. When they say "gigabyte" they actually mean 2^30 bytes. (source) ZeroDark.cloud uses the "GiB" designation instead to prevent confusion.
The second category is requests. And the primary requests are:
GET - whenever a user downloads a file from the cloud
PUT - whenever a user uploads a file to the cloud
All downloads go directly through S3 - no intermediate server is required as read-permissions in ZeroDark.cloud are managed using cryptography. So each download translates into exactly 1 GET request.
For uploads, the ZeroDark server needs to verify write permissions, check eTags, send push notifications, and a bunch of other stuff. So each upload translates into approximately 2 PUT requests.
For estimating your costs, it's often easier to start by estimating the number of uploads performed. You have a little more leeway with downloads. The client SDK gives you full control over what to download & when. This often means you can skip downloading items from the cloud until you need them. For example, when a user first logs into something like a messaging app, the app may choose to only download recent messages in each conversation. Older messages can always be fetched from the cloud if the user requests them.
Push notifications utilize AWS SNS, and the official prices are here.
AWS charges for something called “publishes”, and then they charge per “mobile push notification”. What this means in practice is that every user will have 1 or more devices associated with their account. For example, say Alice has logged in using her phone & an iPad (so 2 devices). When we want to notify Alice that something changed in her account, we use SNS to “publish” a notification to her channel. And since she has 2 devices, this will in turn send 2 different push notifications (1 per device). Therefore, we performed 1 publish, and 2 mobile push notifications.
For each operation that changes something in the cloud, all users with read permissions are notified. For many apps, this simply means the owner of the data. But for messaging systems, this often means the sender & recipient. Remember that if Alice sends a message to Bob (by uploading a file into her bucket with read permissions for Bob, and read-write permissions for herself), then we need to notify all of Bob's devices, and also all of Alice's devices.
For estimating your costs, it may be useful to use the following formula
- Assume N active users
- Assume X operations per user per month (which generate push notifications)
- Assume Y is the average number of users with read permission per operation. For apps that are more sync-oriented, this number will be 1, or close to it. For apps that are more message-oriented, this number will be closer to 2.
- Assume an average of Z devices per user. A good estimate may exceed 1. Maybe 1.1 ?
Plugging in an example cost structure from AWS
- $0.50 per million publishes
- $0.50 per million mobile push notifications
Gives us the following cost estimate:
COST = N * X * (Y + YZ) / 1 million * 0.50
All requests are handled by AWS Lambda, and the official prices are here.
The ZeroDark server is 100% serverless. Here's what that means:
- We write all the server code, and then hand the code to AWS
- AWS waits until it sees a request on our system that needs to be processed
- When that happens, it loads our code onto some server
- Then runs the code so it can process the request
- Afterwards, AWS makes a note of how long it took our code to run
- AWS is then free to unload our code from the server
For billing, this process is split into 2 parts
- The request to run the code
- The amount of time the code took to run
Our slim design utilizes the smallest memory size (128 MB). And in terms of compute time, nearly all requests are fullfilled within 100 milliseconds (which is the smallest billable unit of time).
To get an idea of your compute costs, we first need to understand when compute services are required.
- Uploading files to the cloud will trigger a lambda operation to process the request
- Additionally, the clients will utilize the REST API for various purposes such as
- requesting a list of changes since their last sync
- searching for other users
- various admin tasks, such as registering for push notifications
When the REST API is used, the system utilizes API Gateway to connect an incoming HTTPS request to the lambda code. And the official prices for API Gateway are here.
To estimate your compute costs, it's easiest to differentiate between filesystem operations (whenever the user is trying to modify something in the virtual filesystem), and REST operations (everything else).
Filesystem operations work like this:
- the user uploads a request into the staging area of an S3 bucket
this triggers the ZeroDark code to process the request (via AWS Lambda)
the client uses a REST API to fetch the ZeroDark response
And rest operations work just like you'd expect
- API Gateway receives the incoming HTTPS request
- this triggers the ZeroDark code to process the request (via AWS Lambda)
For estimating your costs, it may be useful to use the following formula
- Assume N active users
- Assume X operations per user per month
- Assume Y REST requests per user per month
Plugging in an example cost structure from AWS:
- $0.0000002 per lambda request
- $0.000000208 per 100 milliseconds of lambda compute
- $3.50 per 1 million API Gateway requests
Would yield an estimate that looks like this:
Lambda Cost = (N * X * 0.0000002) + (N * X * 0.000000208)
API Gateway Cost = (N * X) + (N * Y) / 1 million * $3.50
This is always the hardest to estimate, especially because usage patterns differ so much between apps. However, things become much easier to estimate once you start development because ZeroDark.cloud tracks all this information on a per-user basis. This means you can query the system, and it will report (on a per-user basis):
- number of lambda requests
- lambda CPU time accumulated
- number of API Gateway requests
So as you begin to develop your app, you'll gain a much better understanding concerning your estimated compute costs.
AWS only charges for download bandwidth. You'll see this referenced on most pricing pages. You can find the official pricing at the bottom of the S3 pricing page here.
In general, the bulk of your bandwidth costs will come from downloading files from S3. Which is heavily dependant on the type of application you're creating. However, the ZeroDark client SDK gives you a number of tools to decrease this amount. The SDK will tell you when something has changed, but the client has full control over IF and WHEN to perform the download.
Also, for larger files such as photos, the SDK supports the ability to include metadata & thumbnails alongside the full file content. This allows client applications to download only the thumbnails from the cloud, reducing your bandwidth costs, and speeding up your application too.
An additional fee will be charged according to the following tables.
|Free & Open Source Software||No Fee|
|Cryptocurrency applications||No Fee|
|All other applications||Standard Fee|
|Total Monthly Bill||Fee|
|$5,000 and over||1%|