Skip to content
beeldiPublic

About

PgVolt: high-scale, hardened, drop-in real-time sync for Postgres. An independent fork of ElectricSQL, maintained by Beeldi.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Latest commit

 

History

2,258 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
PgVolt

High-scale, hardened, drop-in real-time sync for Postgres.

PgVolt is an independent fork of Electric, maintained by Beeldi. It is not affiliated with or endorsed by ElectricSQL.
"Electric" and "ElectricSQL" are the upstream project's names.

Why PgVolt?

PgVolt is a drop-in replacement for upstream Electric (ELECTRIC_* configuration, /v1/shape HTTP API, and upstream clients work unchanged), carrying performance, durability, correctness, and security improvements without waiting on upstream to take them.

Performance & scale

Upstream Electric slows down when shape counts climb into the tens or hundreds of thousands, or when bursty writes fan out across many tenants at once: replication slots lag behind Postgres, restarts spike RAM and stall on cold disks, and rolling deploys hang on active long-polls. PgVolt removes those bottlenecks while staying drop-in compatible (synthetic benchmarks vs upstream Electric 1.8.0 6efc8a7d3):

What improves Upstream PgVolt Why it matters
WAL slot catch-up in write storms (opt-in) 49.5 s 6-8 s (6-8x) Keeps Postgres WAL from growing during bursty writes
Multi-tenant filter routing (20k shapes) 23.3 ms 6.0 µs (~3,800x) Removes linear IN + OR and && scans that stall WAL drain
Wide-transaction fan-out (8k shapes / txn) 4.2 s 17 ms (~247x) Eliminates quadratic collector waits when many shapes match
Boot catalog fold RAM (4k shapes) 489.3 MB 2.9 MB (168x less) Prevents boot OOMs as stored shape counts grow
Shape catalog size & cold open (100k shapes) 2.3 GiB / 1x 568 MiB / >10x Cuts catalog disk 4x and slashes cold-cache restart time
Graceful shutdown under live load (200 clients) 14 min (849 s) 1.1 s (~770x) Stops rolling deploys from hanging on open long-poll streams

Also included: 12.5x faster filter index rebuilds (146.4 s to 11.7 s at 40k shapes), >3x faster multi-core boot restore, 4x fewer Postgres round trips per snapshot (8 to 2), 64% less router memory per filter clause, 5.7x lower WAL lag under concurrent live clients (opt-in), and zero-resync Postgres replica failovers (ELECTRIC_KEEP_SHAPES_ON_PROMOTION). See fork/CHANGES.md for all 19 synthetic benchmarks and the 10 opt-in switches.

  • Correctness & formal verification: 121 fixes across Postgres where-clause and subquery parity, crash-safe storage and compaction, and restart recovery, backed by 162 added test files and TLC-checked TLA+ formal verification (fork/tla).
  • Security & hardening: 25+ fixes and defaults, including constant-time Bearer auth, sslmode=verify-ca/verify-full, cache-key Vary isolation, SHA-256 handle digests, credential redaction, bounded query/response/memory limits, and a non-root distroless cc-debian12 release image.
  • Drop-in compatibility: All 10 high-scale/failover switches and 7 experimental HTTP API additions are off by default and tested both off and on in CI.

About this fork

PgVolt maintains the sync service, its telemetry package, and the TypeScript and Elixir clients. Maintenance is best effort and there is no feature roadmap.

Branches

  • main is the default branch for development and upstream integration.
  • feature/* branches are temporary. Target main and delete the branch after merging.
  • release/<version> is cut from a released commit when a release needs a fix that main cannot take. CI already runs on release/**.

Merging upstream

When upstream publishes changes, run git fetch upstream --tags, then scripts/merge_upstream.sh <ref> with a release tag such as @core/sync-service@1.8.1, or upstream/main. The script merges without committing, removes the listed paths again, regenerates the lockfile once no conflict is left, and prints what needs a person: conflicts, new upstream paths, and changesets for removed packages. A new upstream path the fork does not need joins the list in the merge commit.

Table of Contents:

What is Electric?

Sync is the magic ingredient behind fast, modern software. From apps like Figma and Linear to AI agents running on live local data.

Electric is a Postgres sync engine. It solves the hard problems of sync for you, including partial replication, fan-out, and data delivery. So you can build awesome software, without rolling your own sync.

Specifically, Electric is a read-path sync engine for Postgres. It syncs data out of Postgres into ... anything you like. The core sync protocol is based on a low-level HTTP API. This integrates with CDNs for highly-scalable data delivery.

Partial replication is managed using Shapes. Sync can be consumed directly or via client libraries and framework integrations.

Getting Started

See the Quickstart guide to get up and running. In short, you need to:

  1. have a Postgres database with logical replication enabled; and then to
  2. run Electric in front of it, connected via DATABASE_URL

For example, using Docker Compose from the root of this repo. --build builds the sync service from this checkout; without it Compose pulls upstream's image:

docker compose -f .support/docker-compose.yml up --build

You can then use the HTTP API to sync data from your Postgres. For example, to start syncing the whole foo table:

curl -i 'http://localhost:3000/v1/shape?table=foo&offset=-1'

Or use one of the clients or integrations, such as the useShape React hook:

import { useShape } from '@electric-sql/react'

function Component() {
  const { data } = useShape({
    url: `http://localhost:3000/v1/shape`,
    params: {
      table: `foo`,
      where: `title LIKE 'foo%'`,
    },
  })

  return JSON.stringify(data)
}

Again, see the Quickstart and the Docs for more details.

HTTP API Docs

The HTTP API is defined in an OpenAPI spec in upstream's website/electric-api.yaml.

Phoenix LiveDashboard

Electric includes an optional Phoenix LiveDashboard for real-time monitoring of the running system (VM metrics, process info, ETS tables, etc.).

To enable it, set the ELECTRIC_LIVE_DASHBOARD_PORT environment variable:

ELECTRIC_LIVE_DASHBOARD_PORT=4000

The dashboard will be available at http://localhost:4000 (or whichever port you choose). When the variable is not set, the dashboard is not started.

In this fork the dashboard listens on loopback only, 127.0.0.1 or ::1 with ELECTRIC_LISTEN_ON_IPV6=true. Set ELECTRIC_LIVE_DASHBOARD_ADDRESS, for example to 0.0.0.0, to reach it from another host.

WARNING: The LiveDashboard endpoint is completely unauthenticated. Anyone with network access to the port can view internal system state. Before listening on another address, you must restrict access to this port using firewall rules, network policies, or similar controls. Do not expose it to the public internet.

Developing Electric

We use asdf to install Elixir, Erlang, and Node.js. Versions are defined in .tool-versions.

Mac setup

brew install asdf
asdf plugin add nodejs
asdf plugin add pnpm
asdf plugin add elixir
asdf plugin add erlang
asdf install

You'll probably need to fiddle with your bash/zsh/etc rc file to load the right tool into your environment.

Running Tests

Electric has comprehensive test suites for both Elixir and TypeScript components.

Prerequisites

Install dependencies (if not already done):

asdf install
pnpm install

Then start the test Postgres database:

cd packages/sync-service
mix start_dev

This starts a Docker Compose setup with Postgres configured for logical replication on port 54321.

To stop the database:

mix stop_dev

Elixir Tests

Sync Service:

cd packages/sync-service
mix test

For coverage reports:

mix coveralls.html

Elixir Client:

cd packages/elixir-client
mix test

TypeScript Tests

TypeScript tests require both the database and a running sync service.

In a separate terminal, start the sync service:

cd packages/sync-service
iex -S mix

Then run the tests:

cd packages/typescript-client
pnpm test

For coverage:

cd packages/typescript-client
pnpm coverage

Contributing

See the:

Support

Open an issue in this repository for bugs in the fork. Questions about Electric in general are better served by upstream's documentation and community.

About

PgVolt: high-scale, hardened, drop-in real-time sync for Postgres. An independent fork of ElectricSQL, maintained by Beeldi.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages