You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PgDog is a transaction pooler and logical replication manager that can shard PostgreSQL.
8
-
Spiritual successor to [pgcat](https://github.com/levkk/pgcat) and written in Rust, PgDog comes with a lot of
9
-
the same features, like load balancing, failover and connection pooling. In addition, PgDog improves performance and adds new features like cross-shard queries, async protocol support, and sharded `COPY`.
7
+
PgDog is a transaction pooler and logical replication manager that can shard PostgreSQL. Written in Rust, PgDog is fast, secure and can manage hundreds of databases and hudreds of thousands of connections.
10
8
11
9
## Documentation
12
10
13
-
📘 PgDog documentation can be **[found here](https://docs.pgdog.dev/).**
11
+
📘 PgDog documentation can be **[found here](https://docs.pgdog.dev/)**. Any questions? Join our **[Discord](https://discord.gg/jf5A6VES)**.
14
12
15
13
## Quick start
16
14
17
-
You can try PgDog by using Docker. Make sure to install [Docker Compose](https://docs.docker.com/compose/) and run the following:
15
+
You can try PgDog using Docker. Install [Docker Compose](https://docs.docker.com/compose/) and run:
18
16
19
17
```
20
18
docker-compose up
@@ -36,23 +34,56 @@ SELECT * FROM users WHERE id = 1;
36
34
SELECT*FROM payments WHERE user_id =1;
37
35
```
38
36
37
+
## Features
38
+
39
+
40
+
### Load balancer
41
+
42
+
PgDog is an application layer (OSI Level 7) load balancer for PostgreSQL. It can proxy multiple replicas (and primary) and distribute transactions evenly between databases. It supports multiple strategies, including round robin, random, least active connections, etc. PgDog can also inspect queries and send `SELECT` queries to replicas, and all others to the primary. This allows to proxy all databases behind a single PgDog deployment.
PgDog maintains a real-time list of healthy hosts. When a host fails a healthcheck, it's removed from active rotation and queries are rerouted to other databases. This is similar to HTTP load balancing, except it's at the database layer.
49
+
50
+
Failover maximizes database availability and protects against bad network connections, temporary hardware failures or misconfiguration.
PgDog is able to handle databases with multiple shards by routing queries automatically to one or more shards. Using the native PostgreSQL parser, PgDog understands queries, extracts sharding keys and determines the best routing strategy. For cross-shard queries, PgDog assembles results in memory and sends them all to the client transparently.
64
+
65
+
#### Using `COPY`
39
66
40
-
## Features summary
67
+
PgDog comes with a CSV parser and can split COPY commands between all shards automatically. This allows clients to ingest data into sharded PostgreSQL without preprocessing.
41
68
42
-
| Feature | Status | Summary |
43
-
|---------|--------|---------|
44
-
|[Load balancer](https://docs.pgdog.dev/features/load-balancer)| Operational | Spread `SELECT` queries across multiple replicas automatically, using algorithms like round robin. |
45
-
|[Transaction pooling](https://docs.pgdog.dev/features/transaction-mode)| Operational | Identical to pgbouncer, allows for thousands of clients to reuse a handful of server connections. |
46
-
|[Session pooling](https://docs.pgdog.dev/features/session-mode)| Operational | Exclusive use of server connections for clients needing session-level features. |
47
-
|[Plugins](https://docs.pgdog.dev/features/docs/plugins/)| Operational | Control how PgDog routes queries and what results it sends to clients, through loading shared libraries at runtime. |
48
-
|[Sharding](https://docs.pgdog.dev/features/sharding/)| Work in progress | Automatically split data and queries between multiple databases, scaling writes horizonally. |
49
-
|[Authentication](https://docs.pgdog.dev/features/authentication/)| Supports `scram-sha-256` and `trust`| Suppport for various PostgreSQL authentication mechanisms, like SCRAM, MD5, and LDAP. |
50
-
|[Configuration](https://docs.pgdog.dev/configuration/)| Operational | Configure PgDog without restarting the pooler or breaking connections. |
69
+
#### Logical replication
51
70
52
-
## Getting started
71
+
PgDog understands the PostgreSQL logical replication protocol and can split data between databases in the background and without downtime. This allows to shard existing databases and add more shards to existing clusters in production, without impacting database operations.
PgDog is an application layer (OSI Level 7) load balancer for PostgreSQL. It can proxy multiple replicas (and primary) and distribute transactions. It comes with support for multiple strategies, including round robin and random. Additionally, it can parse queries and send `SELECT` queries to replicas and all others to the primary. This allows to proxy all databases behind a single PgDog deployment.
PgDog comes with its own plugin system that loads them at runtime using a shared library interface.
145
-
If a plugin can expose a predefined C API, it can be written in any language, including C/C++, Rust, Zig, Go, Python, Ruby, Java, and many more.
146
-
147
-
Plugins can be used to route queries to specific databases in a sharded configuration, or to
148
-
split traffic between writes and reads in a mixed (primary & replicas) deployment. The plugin
149
-
interface allows code execution at multiple stages of the request/response lifecycle, and can
150
-
go as far as block or intercept queries and return custom results to the client.
151
-
152
-
Examples of plugins can be found in [examples](https://github.com/levkk/pgdog/tree/main/examples) and [plugins](https://github.com/levkk/pgdog/tree/main/plugins).
PgDog is able to handle databases with multiple shards by routing queries automatically to one or more shards. The `pgdog-routing` plugin parses
161
-
queries, extracts tables and columns information, and calculates which shard(s) the query should go to based on the parameters. Not all operations are supported, but
While a lot of "classic" features of PgDog, like load balancing and healthchecks, have been well tested in production and at scale, the current codebase has not. This project is just getting started and early adopters are welcome to try PgDog internally.
195
-
196
-
Status on features stability will be [updated regularly](https://docs.pgdog.dev/features/).
161
+
This project is just getting started and early adopters are welcome to try PgDog internally. Status on features stability will be [updated regularly](https://docs.pgdog.dev/features/). Most features have tests and are benchmarked regularly for performance regressions.
197
162
198
163
## Performance
199
164
200
-
PgDog does its best to minimize its impact on overall database performance. Using Rust and Tokio is a great start for a fast network proxy, but additional
201
-
care is also taken to perform as few operations as possible while moving data between client and server sockets. Some benchmarks are provided
202
-
to help set a baseline.
165
+
PgDog does its best to minimize its impact on overall database performance. Using Rust and Tokio is a great start for a fast network proxy, but additional care is also taken to perform as few operations as possible while moving data between client and server sockets. Some benchmarks are provided to help set a baseline.
0 commit comments