![[res_network.png|64]]
Network is consumed when Postgres communicates with clients, replicas, or foreign data sources. All client communication goes through the postmaster's socket; replication adds additional streams.
- **Visibility**: [[Client]] wait events, [[IPC]] (replication coordination), [[LWLock]] (`SyncRep`)
## Key Concepts
## Client Protocol
- **Description**: Postgres uses the pq wire protocol over TCP (or Unix socket). Each backend handles exactly one client connection
- **Impact**: `ClientRead` / `ClientWrite` waits mean the backend is blocked waiting on the client — often slow clients or large result sets
## Streaming Replication
- **Description**: WAL is streamed from primary to standby via a dedicated `walsender` / `walreceiver` pair. The standby applies WAL continuously
- **Impact**: `WalSenderWaitForWAL` (Client), `WalReceiverMain` (Activity), `SyncRep` (LWLock/IPC) waits
## Synchronous Replication
- **Description**: With `synchronous_commit = on`, the primary waits for the standby to confirm WAL receipt before acknowledging the transaction commit
- **Impact**: `SyncRep` IPC wait on every write transaction; network latency directly adds to transaction commit time
## Logical Replication
- **Description**: Higher-level replication of individual table changes, used for selective replication or cross-version migration
- **Impact**: `LogicalSyncData`, `LogicalSyncStateChange`, `LogicalApplySendData` IPC waits; `LibPQWalReceiverConnect/Receive` Client waits
## Foreign Data Wrappers / Custom Scans
- **Description**: FDWs (`postgres_fdw`, etc.) open their own network connections to remote servers during query execution
- **Impact**: `ClientRead`/`ClientWrite` Client waits from the perspective of the remote; latency adds directly to query time
## Key Config Parameters
| Parameter | Default | Purpose |
|---|---|---|
| `max_connections` | 100 | Max simultaneous client connections |
| `synchronous_commit` | `on` | Wait for WAL to be confirmed by standby before returning |
| `synchronous_standby_names` | (empty) | Which standbys must confirm WAL for synchronous commit |
| `wal_sender_timeout` | 60 s | Timeout for WAL sender connections |
| `wal_receiver_timeout` | 60 s | Timeout for WAL receiver connections |
| `tcp_keepalives_idle` | 0 (OS default) | Seconds before TCP keepalive probes begin |
| `tcp_keepalives_interval` | 0 (OS default) | Seconds between keepalive probes |
| `tcp_keepalives_count` | 0 (OS default) | Number of keepalive probes before giving up |
## Related Workloads
- [[Client]] — all client/replication network wait events
- [[IPC]] (`SyncRep`, `LogicalSyncData`, `WalReceiverWaitStart`)
- [[LWLock]] (`SyncRep`, `ReplicationSlotControl`)