This article is written by Zach Goldie
Cost Analysis of Self-Hosting OTA Updates
An important consideration for app developers managing over-the-air (OTA) updates is understanding the costs involved, particularly when the app has millions of users. This analysis sheds light on the monthly costs of hosting Codemagic Patch on DigitalOcean for three different user scales: 10,000, 1 million, and 100 million monthly active users (MAU).
Cost Breakdown for Different User Levels
| Monthly Users | 10,000 | 1 Million | 100 Million |
|---|---|---|---|
| DigitalOcean | $12 | $63 | approximately $843 |
| Cloudflare | $0 | $0 | $0 |
| License | $0 | $0 | $7,250 |
| Total | $12 | $63 | approximately $8,093 |
Requirements for Hosting Codemagic Patch
Patch is built for ease of deployment and flexibility. Essential components include:
- A server for metrics, dashboard, and publishing tasks
- Object storage for manifests and bundles
- Postgres for storing metric rows and release records
- An optional CDN in front of the storage hostname for manifests and bundles
Traffic Insights for Codemagic Patch
Requests Overview
Devices will request updates via meta.json and manifest.json, files that are created with each release and stored in object storage, served by the CDN. This design minimizes server load by routing requests primarily through the CDN.
Posts Overview
Each device posts statuses such as Downloaded, Ready, and Applied. The status Active is updated daily to reflect the current state of the device. Initially stored individually, these updates are aggregated into daily totals after eight days.
Load Estimates for 100 Million Users
Estimating user interaction, we assume that one-fourth of monthly active users open the app daily, resulting in 25 million update checks and Active posts each day. Furthermore, we predict one OTA update release weekly, leading to three additional post events per device during an update.
| 10,000 | 1 Million | 100 Million | |
|---|---|---|---|
| Opens per Day | 2,500 | 250,000 | 25 Million |
| Active Posts Average (24 hours) | Under 1/sec | About 3/sec | About 300/sec |
| Active Posts (8-hour Bunched Day) | Under 1/sec | About 10/sec | About 1,000/sec |
Infrastructure Sizing Guidelines
The droplet should be sized based on the expected Active posts, taking into account added traffic from release days.
Server Specifications and Throughput
A virtual machine (VM) with dedicated CPU resources will help in managing incoming metrics. The foundational configuration on DigitalOcean includes 2 vCPUs and 8 GiB of RAM for $63 per month. Load testing demonstrated that this setup efficiently handles around 750 posts per second to a managed Postgres.
Managed Postgres Requirements
To support the database needs, a managed service is recommended, with an estimate of 4 GiB per 1 million monthly users. For 100 million users, an 800 GiB instance will suffice, augmented with the necessary backup features, estimated at $352 per month on DigitalOcean.
Data Roll-up Duration
On peak days, consolidating 50 million rows can take about 25 minutes; however, during this period, new posts continue to be stored.
Ensuring Redundancy
Redundancy is essential to maintain service during system failures. The following components should be included:
- A standby database node that can be activated if the primary node fails.
- A second 2 vCPU droplet for load balancing metric posts and publishing.
- A load balancer directing traffic between drops to ensure seamless operation.
Monthly Data Transfer Considerations
The total download volume for devices can reach around a petabyte monthly. Utilizing Cloudflare as a CDN allows bandwidth costs to remain negligible, as egress for stored artifacts is effectively free.
Unnecessary Components
Due to the CDN offloading requests, several typical server components are not required:
- No queuing systems since devices retry posts if needed.
- No HTTP cache for API requests, as the important files are cached by the CDN.
- No requirement for Redis, given that essential metadata is stored in Postgres.
- No Kubernetes or API gateway necessary, as two droplets manage redundancy.
- No autoscaling since traffic created by downloads does not reach the server.
- No multi-region Postgres needed for query efficiency.
- Potentially no timeseries databases required for enhanced performance insights.
Monthly Cost Summary
At the scale of 100 million users, the monthly cost structure is detailed as follows:
| Line Item | Description | Cost |
|---|---|---|
| Two API droplets | 2 vCPUs and 8 GiB each | $126 |
| Load Balancer | Handles metric posts and publishing traffic | $12 |
| Managed Postgres | 4 vCPUs, 16 GiB, 800 GiB storage | $352 |
| Standby Database Node | Redundancy for primary database | $352 |
| Droplet Egress | Metric responses, included in droplet transfer | $0 |
| R2 Storage | Artifact storage with no egress cost | approximately $1 |
| Cloudflare | CDN caching | $0 |
| Infrastructure Total | approximately $843 | |
| Licensing Fees | Applicable above 1 million users | $7,250 |
| Overall Total | approximately $8,093 |
Explore Codemagic Patch
For additional details on Codemagic Patch and its documentation, visit patch.codemagic.io. A local evaluation stack for personal testing is also available.
Interested parties managing over a million users can reach out to sales@codemagic.io for further information.
Frequently Asked Questions
Is the license free for under a million users?
Yes, the license is free for applications with at or below 1 million monthly active users. A fee applies for additional users above this threshold.
Does Cloudflare incur additional costs per download?
The CDN serves update checks and bundles, maintaining a cost of $0 for this functionality in the total estimate.
Is DigitalOcean mandatory for hosting?
Codemagic Patch is compatible with any Linux machine. DigitalOcean is utilized here purely as an example, with alternatives including AWS, GCP, or Fly.io.
Chief Editor of Quincy City Beat — Quincy, MA's independent investigative newspaper covering Greater Boston and the entire Commonwealth of Massachusetts with fearless public accountability and free access for all readers.










Discussion about this post