Table of Content

Table of Content

How to Set Up a Self-Hosted Billing System on Your Own Infrastructure

How to Set Up a Self-Hosted Billing System on Your Own Infrastructure

How to Set Up a Self-Hosted Billing System on Your Own Infrastructure

How to Set Up a Self-Hosted Billing System on Your Own Infrastructure

How to Set Up a Self-Hosted Billing System on Your Own Infrastructure

5 mins

5 mins

flexprice logo

Team Flexprice

Editorial

Setting up a self-hosted billing system on your own infrastructure means running an open source billing engine and its data stores inside your own perimeter. With Flexprice that's PostgreSQL, ClickHouse, Kafka and Temporal under AGPL-3.0. I work here, so discount the sales parts and check the numbers. Most guides stop at the setup command. Keeping it alive is the hard part.

Key Takeaways

  • Self-hosted usage billing needs six roles filled: PostgreSQL, ClickHouse, Kafka, Temporal, S3 and Redis in Flexprice's case.

  • Flexprice's AWS reference costs about $5,500 a month at 100 million events.

  • GDPR Article 44 restricts moving personal data outside the EU, so billing location is a legal question.

  • Flexprice has no separate community edition: the AGPL-3.0 repo is the same engine Flexprice Cloud runs.

How do you self host a billing system?

You self host a billing system by standing up the data tier, then the engine, then your events. Six steps, from the Flexprice self-hosting docs.

  1. Check prerequisites. Go 1.23 or later, Docker and Docker Compose, and make, on Linux, macOS or WSL.

  2. Clone the repository. git clone https://github.com/flexprice/flexprice gets the whole engine under AGPL-3.0, not a trimmed community build.

  3. Run make dev-setup. It starts PostgreSQL, Kafka, ClickHouse and Temporal, runs both migration sets, seeds a tenant, and starts the API, Consumer and Worker.

  4. Verify. The API answers on localhost:8080, Temporal on 8088, ClickHouse on 8123. Send a test event and find it in the Usage Metering event debugger.

  5. Move to production. Swap Compose for ECS or Kubernetes, Aurora PostgreSQL, Amazon MSK, ClickHouse on EKS, and ElastiCache.

  6. Harden it. TLS externally, rotated secrets, database replication, multi-broker Kafka, backups.

What are the infrastructure requirements for self hosted billing?

Self hosted billing needs six infrastructure roles filled, and Flexprice fills them with PostgreSQL, ClickHouse, Kafka, Temporal, S3 and Redis. Each role earns its place:

  • PostgreSQL holds customers, plans, entitlements and invoices, because billing state needs transactions and joins.

  • ClickHouse stores usage events, because aggregating billions of rows inside a billing run needs a columnar store.

  • Kafka absorbs ingestion, so a slow consumer never blocks your customer's API call.

  • Temporal drives billing cycles and retries, so a failed invoice run resumes where it stopped.

  • S3 keeps invoice PDFs, since object storage costs less than a database for files nobody queries.

  • Redis caches hot balance reads, and it's the one optional piece: our docs call a missing Redis non-fatal in local development.

Our published sizing at 100 million events a month runs 6 API tasks, 30 Consumer tasks and 3 Worker tasks against Aurora and two MSK brokers.

Setting up a self-hosted billing system on your own infrastructure means running an open source billing engine and its data stores inside your own perimeter. With Flexprice that's PostgreSQL, ClickHouse, Kafka and Temporal under AGPL-3.0. I work here, so discount the sales parts and check the numbers. Most guides stop at the setup command. Keeping it alive is the hard part.

Key Takeaways

  • Self-hosted usage billing needs six roles filled: PostgreSQL, ClickHouse, Kafka, Temporal, S3 and Redis in Flexprice's case.

  • Flexprice's AWS reference costs about $5,500 a month at 100 million events.

  • GDPR Article 44 restricts moving personal data outside the EU, so billing location is a legal question.

  • Flexprice has no separate community edition: the AGPL-3.0 repo is the same engine Flexprice Cloud runs.

How do you self host a billing system?

You self host a billing system by standing up the data tier, then the engine, then your events. Six steps, from the Flexprice self-hosting docs.

  1. Check prerequisites. Go 1.23 or later, Docker and Docker Compose, and make, on Linux, macOS or WSL.

  2. Clone the repository. git clone https://github.com/flexprice/flexprice gets the whole engine under AGPL-3.0, not a trimmed community build.

  3. Run make dev-setup. It starts PostgreSQL, Kafka, ClickHouse and Temporal, runs both migration sets, seeds a tenant, and starts the API, Consumer and Worker.

  4. Verify. The API answers on localhost:8080, Temporal on 8088, ClickHouse on 8123. Send a test event and find it in the Usage Metering event debugger.

  5. Move to production. Swap Compose for ECS or Kubernetes, Aurora PostgreSQL, Amazon MSK, ClickHouse on EKS, and ElastiCache.

  6. Harden it. TLS externally, rotated secrets, database replication, multi-broker Kafka, backups.

What are the infrastructure requirements for self hosted billing?

Self hosted billing needs six infrastructure roles filled, and Flexprice fills them with PostgreSQL, ClickHouse, Kafka, Temporal, S3 and Redis. Each role earns its place:

  • PostgreSQL holds customers, plans, entitlements and invoices, because billing state needs transactions and joins.

  • ClickHouse stores usage events, because aggregating billions of rows inside a billing run needs a columnar store.

  • Kafka absorbs ingestion, so a slow consumer never blocks your customer's API call.

  • Temporal drives billing cycles and retries, so a failed invoice run resumes where it stopped.

  • S3 keeps invoice PDFs, since object storage costs less than a database for files nobody queries.

  • Redis caches hot balance reads, and it's the one optional piece: our docs call a missing Redis non-fatal in local development.

Our published sizing at 100 million events a month runs 6 API tasks, 30 Consumer tasks and 3 Worker tasks against Aurora and two MSK brokers.

Get started with your billing today.

Get started with your billing today.

Which open source billing platforms support self hosting?

Flexprice publishes code you can run yourself, and Orb's pricing page listed no self-hosting option as of 9 August 2026. What separates them is which capabilities ship in the tier you can run, which we compare across open source options for usage-based billing:

Flexprice publishes one engine under AGPL-3.0 on a repo with 4,000+ stars, and make dev-setup runs the same image Flexprice Cloud runs, in three roles.

What are the data residency and control benefits of on prem billing?

On prem billing keeps usage events, which carry customer identifiers, inside the jurisdiction your regulators require. GDPR Article 44 permits transfers to a third country only under the conditions in Chapter V. Gartner forecasts $80 billion of sovereign cloud IaaS spending in 2026, up 35.6% on 2025.

The two paths differ in how much lands on you:

  • DIY self-hosting means you clone the repo and own the on-call yourself.

  • A managed on-premise or VPC deployment on the Mission Critical plan runs the same engine inside your perimeter, with SOC 2 Type 2 compliance, a custom SLA, and an air-gapped option.

One CTO chose the second: "We weren't willing to give up control of our data, but we still needed a reliable subscription tool. Flexprice on-prem was the only thing that worked for us." - Martin Sønderkær Jung, CTO

Is self hosted or SaaS billing cheaper in total cost?

Self hosted billing wins on cost only when your platform team already runs these components, because it swaps a subscription line for engineering time teams underestimate.


Cost line

Self-hosted

Managed

Infrastructure

~$5,500/mo at 100M events, per Flexprice's AWS reference

Included

Engineering time

4 to 8 hours a week on ClickHouse operations alone, $1,600-4,800/mo, per Tinybird, who sell managed ClickHouse

Zero

Subscription

$0, AGPL-3.0

Free, $500/mo or $1,000/mo, 20% off yearly, never a share of revenue

Either column has to survive your volume. Flexprice runs 20B+ events monthly at 60K+ events per second, under 60ms P99, for 100+ customers including Simplismart, Segwise and Vapi. We've costed building billing in-house separately.

What is the upgrade and maintenance burden of on prem billing?

The upgrade and maintenance burden of on prem billing is permanent, because your on-call rotation now covers revenue and a Kafka partition problem at 2am becomes an invoicing incident. Three things recur:

  • Version upgrades land migrations on both databases, so one release touches PostgreSQL and ClickHouse together.

  • Replication, backups and secret rotation stay your job forever.

  • Self-hosted deployments replay from Kafka and S3, without the DynamoDB redundancy buffer we run in Flexprice Cloud.

Simplismart's billing engine ate 20 to 30% of a developer's day until they moved to Flexprice, which gave back 30% of that bandwidth and $145K+ a year.

Frequently asked questions

What does a self-hosted billing stack actually run on?

A transactional database, a columnar store for usage events, an event broker, a workflow engine, and object storage for invoice PDFs. In Flexprice: PostgreSQL, ClickHouse, Kafka, Temporal and S3.

When does self-hosting billing actually save money?

Only when your platform team already runs the same components for something else. Flexprice's AWS reference costs roughly $5,500 a month at 100 million events before engineering time, against managed plans of free to $1,000 a month, or 20% less billed yearly.

What do I have to maintain after go-live?

Version upgrades, migrations on both databases, replication, backups, secret rotation, and an on-call rotation that now covers revenue.

Where should you start?

Start by running make dev-setup and comparing the component list against what your platform team runs today. If Kafka and a columnar store are there, billing adds one service; if not, four. Clone it at github.com/flexprice/flexprice.

Which open source billing platforms support self hosting?

Flexprice publishes code you can run yourself, and Orb's pricing page listed no self-hosting option as of 9 August 2026. What separates them is which capabilities ship in the tier you can run, which we compare across open source options for usage-based billing:

Flexprice publishes one engine under AGPL-3.0 on a repo with 4,000+ stars, and make dev-setup runs the same image Flexprice Cloud runs, in three roles.

What are the data residency and control benefits of on prem billing?

On prem billing keeps usage events, which carry customer identifiers, inside the jurisdiction your regulators require. GDPR Article 44 permits transfers to a third country only under the conditions in Chapter V. Gartner forecasts $80 billion of sovereign cloud IaaS spending in 2026, up 35.6% on 2025.

The two paths differ in how much lands on you:

  • DIY self-hosting means you clone the repo and own the on-call yourself.

  • A managed on-premise or VPC deployment on the Mission Critical plan runs the same engine inside your perimeter, with SOC 2 Type 2 compliance, a custom SLA, and an air-gapped option.

One CTO chose the second: "We weren't willing to give up control of our data, but we still needed a reliable subscription tool. Flexprice on-prem was the only thing that worked for us." - Martin Sønderkær Jung, CTO

Is self hosted or SaaS billing cheaper in total cost?

Self hosted billing wins on cost only when your platform team already runs these components, because it swaps a subscription line for engineering time teams underestimate.


Cost line

Self-hosted

Managed

Infrastructure

~$5,500/mo at 100M events, per Flexprice's AWS reference

Included

Engineering time

4 to 8 hours a week on ClickHouse operations alone, $1,600-4,800/mo, per Tinybird, who sell managed ClickHouse

Zero

Subscription

$0, AGPL-3.0

Free, $500/mo or $1,000/mo, 20% off yearly, never a share of revenue

Either column has to survive your volume. Flexprice runs 20B+ events monthly at 60K+ events per second, under 60ms P99, for 100+ customers including Simplismart, Segwise and Vapi. We've costed building billing in-house separately.

What is the upgrade and maintenance burden of on prem billing?

The upgrade and maintenance burden of on prem billing is permanent, because your on-call rotation now covers revenue and a Kafka partition problem at 2am becomes an invoicing incident. Three things recur:

  • Version upgrades land migrations on both databases, so one release touches PostgreSQL and ClickHouse together.

  • Replication, backups and secret rotation stay your job forever.

  • Self-hosted deployments replay from Kafka and S3, without the DynamoDB redundancy buffer we run in Flexprice Cloud.

Simplismart's billing engine ate 20 to 30% of a developer's day until they moved to Flexprice, which gave back 30% of that bandwidth and $145K+ a year.

Frequently asked questions

What does a self-hosted billing stack actually run on?

A transactional database, a columnar store for usage events, an event broker, a workflow engine, and object storage for invoice PDFs. In Flexprice: PostgreSQL, ClickHouse, Kafka, Temporal and S3.

When does self-hosting billing actually save money?

Only when your platform team already runs the same components for something else. Flexprice's AWS reference costs roughly $5,500 a month at 100 million events before engineering time, against managed plans of free to $1,000 a month, or 20% less billed yearly.

What do I have to maintain after go-live?

Version upgrades, migrations on both databases, replication, backups, secret rotation, and an on-call rotation that now covers revenue.

Where should you start?

Start by running make dev-setup and comparing the component list against what your platform team runs today. If Kafka and a columnar store are there, billing adds one service; if not, four. Clone it at github.com/flexprice/flexprice.

Share it on:

Ship Usage-Based Billing with Flexprice

Ship Usage-Based Billing with Flexprice

Ship Usage-Based Billing with Flexprice

More insights on billing

More insights on billing

Get Instant Feedback on Your Pricing | Join the Flexprice Community with 400+ Builders on Slack

Join the Flexprice Community on Slack