-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename PG Bouncer to PG Event Distributor
- Loading branch information
Showing
7 changed files
with
57 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
## PG Event Distributor | ||
|
||
The PG event distributor, is designed to enhance PGCacheWatch by enabling efficient distribution of PostgreSQL notifications to multiple clients. This service acts as a middleware, receiving notifications from PostgreSQL and broadcasting them to connected clients via WebSockets. This "fan-out" effect ensures real-time cache invalidation across all clients with minimal database connections. | ||
|
||
### Key Benefits: | ||
|
||
- **Scalability**: Handles numerous clients without increasing load on the PostgreSQL server. | ||
- **Efficiency**: Reduces the need for multiple direct connections to PostgreSQL for NOTIFY/LISTEN. | ||
- **Real-time**: Ensures immediate cache invalidation across services upon database changes. | ||
|
||
### Illustration: | ||
|
||
``` | ||
+-------------------+ | ||
| PostgreSQL DB | | ||
| - NOTIFY on event | | ||
+---------+---------+ | ||
| | ||
| NOTIFY | ||
| | ||
+---------v-------------+ | ||
| PG Event Distributor | | ||
| Service | | ||
| - Fan-out NOTIFY | | ||
+---------+-------------+ | ||
| | ||
+-------------+-------------+ | ||
| | | ||
+-------v-------+ +-------v-------+ | ||
| WebSocket | | WebSocket | | ||
| Client 1 | | Client N | | ||
| - Invalidate | | - Invalidate | | ||
| Cache | | Cache | | ||
+---------------+ +---------------+ | ||
``` | ||
|
||
To leverage the PG Event Distributor within your PGCacheWatch setup, ensure it's running and accessible by your application. Configure PGCacheWatch to connect to the PG Event Distributor instead of directly to PostgreSQL for notifications. This setup amplifies the effectiveness of your cache invalidation strategy by ensuring timely updates across all client caches with optimized resource usage. | ||
|
||
### Running the PG Event Distributor | ||
To start the PG Event Distributor service, use the following command in your terminal. This command utilizes uvicorn, an ASGI server, to run the service defined in the `pgcachewatch.pg_event_distributor:main` module. The --factory flag is used to indicate that uvicorn should call the provided application factory function to get the ASGI application instance. | ||
|
||
```bash | ||
uvicorn pgcachewatch.pg_event_distributor:main --factory | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters