Back to Electric

Postgres Sync

website/products/postgres-sync.md

latest3.7 KB
Original Source
<script setup> import ComponentsJPG from '/static/img/docs/guides/deployment/components.jpg?url' import ComponentsPNG from '/static/img/docs/guides/deployment/components.png?url' import ComponentsSmPNG from '/static/img/docs/guides/deployment/components.sm.png?url' import BlogPostsByTag from '../src/components/BlogPostsByTag.vue' import GitHubButton from '../src/components/GitHubButton.vue' </script>

Postgres Sync

Read-path sync engine for Postgres that handles partial replication, <span class="no-wrap-sm"> data delivery and <span class="no-wrap"> fan-out</span></span>.

<div class="actions cta-actions page-footer-actions left"> <div class="action"> <VPButton href="/docs/quickstart" text="Quickstart" theme="brand" /> </div> <div class="action"> <GitHubButton repo="electric-sql/electric" /> </div> </div>

Postgres sync engine

Postgres Sync is a sync engine that syncs subsets of your data out of your Postgres database, into local apps and services.

You can sync data into anything you like. From web, mobile and desktop apps and client stores like TanStack DB to databases like PGlite.

<div style="margin-top: 40px;">

[!Warning] 🎓  A quick note on naming Postgres Sync used to just be called "Electric" or the "Electric sync engine". Some docs and package names still use the old naming.

</div>

How does it work?

Postgres Sync connects to your Postgres using a DATABASE_URL, consumes the logical replication stream and fans out data into Shapes, which Clients then consume and sync.

<figure> <a href="/img/api/shape-log.jpg"> </a> <figcaption class="figure-caption text-end"> Shape log flow diagram. </figcaption> </figure>

Technically, Postgres Sync is an Elixir application, developed at packages/sync-service. It runs as a seperate service, between your API and your database. Clients consume data over an HTTP API that works with CDNs to scale data delivery and fan-out.

<figure> <a :href="ComponentsJPG"> </a> </figure>

This allows you to have millions of concurrent users subscribing to real-time updates to your database with minimal additional load on your database.

<BlogPostsByTag tag="postgres-sync" :limit="4" />

More information

See the Quickstart, Docs and Demos.

<div class="actions cta-actions page-footer-actions left"> <div class="action"> <VPButton href="/docs/quickstart" text="Quickstart" theme="brand" /> </div> <div class="action"> <GitHubButton repo="electric-sql/electric" text="Star on GitHub" /> </div> </div>