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
Copy file name to clipboardexpand all lines: README.md
+29-51
Original file line number
Diff line number
Diff line change
@@ -36,84 +36,54 @@ SELECT * FROM payments WHERE user_id = 1;
36
36
37
37
## Features
38
38
39
+
39
40
### Load balancer
40
41
41
-
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.
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 in its database configuration.
48
-
When a host fails a healthcheck, it's removed from active rotation
49
-
and queries are rerouted to other replicas. This is analogous to modern HTTP
50
-
load balancing, except it's at the database layer.
48
+
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.
51
49
52
-
Failover maximizes database availability and protects against intermittent issues like spotty network connectivity and temporary downtime.
50
+
Failover maximizes database availability and protects against bad network connections, temporary hardware failures or misconfiguration.
PgDog comes with its own plugin system that loads them at runtime using a shared library interface.
66
-
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.
67
-
68
-
Plugins can be used to route queries to specific databases in a sharded configuration, or to
69
-
split traffic between writes and reads in a mixed (primary & replicas) deployment. The plugin
70
-
interface allows code execution at multiple stages of the request/response lifecycle, and can
71
-
go as far as block or intercept queries and return custom results to the client.
72
-
73
-
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
82
-
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
83
-
a lot of common use cases are working.
63
+
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.
The configuration files for a sharded database are provided in the repository. To make it work locally, create the required databases:
65
+
#### Using `COPY`
90
66
91
-
```postgresql
92
-
CREATE DATABASE shard_0;
93
-
CREATE DATABASE shard_1;
67
+
PgDog come with a CSV parser and can split a COPY command between all shards automatically. This allows clients to ingest data into sharded PostgreSQL without preprocessing.
94
68
95
-
GRANT CONNECT ON DATABASE shard_0 TO pgdog;
96
-
GRANT CONNECT ON DATABASE shard_1 TO pgdog;
97
-
```
69
+
#### Logical replication
98
70
99
-
You can launch PgDog with the sharded configuration using the files provided in the repository:
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.
100
72
101
-
```bash
102
-
cargo run -- --config pgdog-sharded.toml --users users-sharded.toml
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.
180
-
181
-
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.
182
162
183
163
## Performance
184
164
185
-
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
186
-
care is also taken to perform as few operations as possible while moving data between client and server sockets. Some benchmarks are provided
187
-
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