Skip to content

Commit 2dc2557

Browse files
sinadarbouymostafa
andauthored
Update Documentation to Reflect GatewayD’s Support for Multiple Proxies and Configuration Blocks (#61)
* Added Configuration block into glossary * made changes related to loadBalancer in server * made changes related to configuration block for related component clinets, pools,proxies * fixed pool link in Clients md * docs: update environment variables format - Update configuration example to reflect new nested block structure for clients and servers - Adjust environment variable section to include the new five-part structure - Update Mermaid diagram to illustrate the five-part environment variable breakdown * Update using-gatewayd/configuration.md Co-authored-by: Mostafa Moradian <[email protected]> Signed-off-by: sina <[email protected]> * Update using-gatewayd/configuration.md Co-authored-by: Mostafa Moradian <[email protected]> Signed-off-by: sina <[email protected]> * docs: Update README with enhanced server configuration details - Added detailed descriptions for new load balancer configuration options: - `consistentHash` settings with `useSourceIp` parameter. - Support for `loadBalancingRules` and `distribution` parameters for strategies like `WEIGHTED_ROUND_ROBIN`. - Expanded possible values for `loadBalancer.strategy` to include `RANDOM` and `WEIGHTED_ROUND_ROBIN`. - Updated example configuration to reflect the new settings and provide clarity on usage. * Replaced all activeWrites to writes --------- Signed-off-by: sina <[email protected]> Co-authored-by: Mostafa Moradian <[email protected]>
1 parent 7e6dac2 commit 2dc2557

File tree

6 files changed

+101
-60
lines changed

6 files changed

+101
-60
lines changed

miscellaneous/glossary.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
last_modified_date: 2024-05-31 20:16:38
2+
last_modified_date: 2024-07-30 16:55:16
33
layout: default
44
title: Glossary
55
description: Glossary of GatewayD terms
@@ -28,6 +28,11 @@ Each configuration file contains multiple configuration objects that correspond
2828

2929
To enable multi-tenancy, GatewayD supports configuring multiple instances of each (configuration) object using configuration groups. All the default configuration objects have a single configuration group called `default`, except the `API`.
3030

31+
## Configuration block
32+
Within each configuration group, GatewayD allows for further segmentation of settings through the use of configuration blocks. A configuration block represents a specific set of parameters within a configuration group, tailored to a particular instance.
33+
34+
Configuration blocks are supported for the following configuration objects: `clients`, `pools` and `proxies`.
35+
3136
## Configuration parameter
3237

3338
A configuration object has one or many configuration parameters to set up the corresponding object. For example, the `output` parameter on the `logger` object is used to set the outputs by the `default` (configuration group) logger.

using-gatewayd/configuration.md

+36-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
last_modified_date: 2024-05-31 20:16:38
2+
last_modified_date: 2024-07-30 16:36:53
33
layout: default
44
title: Configuration
55
description: GatewayD is fully configurable via various sources, including default values, YAML config files, environment variables, CLI flags and plugins.
@@ -74,28 +74,31 @@ metrics:
7474

7575
clients:
7676
default:
77-
network: tcp
78-
address: localhost:5432
79-
tcpKeepAlive: False
80-
tcpKeepAlivePeriod: 30s # duration
81-
receiveChunkSize: 8192
82-
receiveDeadline: 0s # duration, 0ms/0s means no deadline
83-
receiveTimeout: 0s # duration, 0ms/0s means no timeout
84-
sendDeadline: 0s # duration, 0ms/0s means no deadline
85-
dialTimeout: 60s # duration, 0ms/0s means no timeout
86-
# Retry configuration
87-
retries: 3 # 0 means no retry
88-
backoff: 1s # duration
89-
backoffMultiplier: 2.0 # 0 means no backoff
90-
disableBackoffCaps: false
77+
writes: # ⬅️ Configuration block
78+
network: tcp
79+
address: localhost:5432
80+
tcpKeepAlive: False
81+
tcpKeepAlivePeriod: 30s # duration
82+
receiveChunkSize: 8192
83+
receiveDeadline: 0s # duration, 0ms/0s means no deadline
84+
receiveTimeout: 0s # duration, 0ms/0s means no timeout
85+
sendDeadline: 0s # duration, 0ms/0s means no deadline
86+
dialTimeout: 60s # duration, 0ms/0s means no timeout
87+
# Retry configuration
88+
retries: 3 # 0 means no retry
89+
backoff: 1s # duration
90+
backoffMultiplier: 2.0 # 0 means no backoff
91+
disableBackoffCaps: false
9192

9293
pools:
9394
default:
94-
size: 10
95+
writes:
96+
size: 10
9597

9698
proxies:
9799
default:
98-
healthCheckPeriod: 60s # duration
100+
writes:
101+
healthCheckPeriod: 60s # duration
99102

100103
servers:
101104
default:
@@ -107,6 +110,11 @@ servers:
107110
certFile: ""
108111
keyFile: ""
109112
handshakeTimeout: 5s # duration
113+
loadBalancer:
114+
# Load balancer strategies can be found in config/constants.go
115+
strategy: ROUND_ROBIN
116+
consistentHash:
117+
useSourceIp: true
110118

111119
api:
112120
enabled: True
@@ -158,24 +166,27 @@ plugins:
158166

159167
## Environment variables
160168

161-
All configuration parameters have a corresponding environment variables, except in certain cases. All environment variables are prefixed with `GATEWAYD` and are in snake case. For example, the `GATEWAYD_LOGGERS_DEFAULT_OUTPUT` environment variable can be set to the outputs required by the default logger and consists of four parts:
169+
All configuration parameters have a corresponding environment variables, except in certain cases. All environment variables are prefixed with `GATEWAYD` and are in snake case. For example, the `GATEWAYD_CLIENTS_DEFAULT_WRITES_NETWORK` environment variable can be set to the network type for the writes in the default client configuration and consists of five parts:
162170

163171
1. Prefix: all environment variables are prefixed with `GATEWAYD`.
164-
2. Object: the configuration object, in this case `LOGGERS`.
172+
2. Object: the configuration object, in this case `CLIENTS`.
165173
3. Group: the configuration group, in this case `DEFAULT`.
166-
4. Parameter: the configuration parameter, in this case `OUTPUT`.
174+
4. Block: the configuration block, in this case `WRITES` (if applicable).
175+
5. Parameter: the configuration parameter, in this case `NETWORK`.
167176

168177
```mermaid
169178
flowchart TD
170-
A(GATEWAYD_LOGGERS_DEFAULT_OUTPUT)
179+
A(GATEWAYD_CLIENTS_DEFAULT_WRITES_NETWORK)
171180
A --> GATEWAYD
172-
A --> LOGGERS
181+
A --> CLIENTS
173182
A --> DEFAULT
174-
A --> OUTPUT
183+
A -.-> WRITES
184+
A --> NETWORK
175185
GATEWAYD --> Prefix
176-
LOGGERS --> Object
186+
CLIENTS --> Object
177187
DEFAULT --> Group
178-
OUTPUT --> Parameter
188+
WRITES -.-> Block
189+
NETWORK --> Parameter
179190
```
180191

181192
## Runtime configuration

using-gatewayd/global-configuration/clients.md

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
last_modified_date: 2024-05-31 20:16:38
2+
last_modified_date: 2024-07-29 17:35:18
33
layout: default
44
title: Clients
55
description: GatewayD client configuration
@@ -10,7 +10,7 @@ grand_parent: Using GatewayD
1010

1111
# Clients
1212

13-
GatewayD supports multiple client configurations. Each client in each configuration group will connect to the same database server specified in the configuration parameters and will be added to its corresponding [pool](pools) based on their configuration group, i.e. `default`.
13+
GatewayD supports multiple client configurations. Each client within a configuration group will connect to a database server specified in the configuration parameters and will be added to its corresponding [pool](pools) based on their configuration group (e.g., `default`) and configuration block (e.g., `writes`).
1414

1515
## Configuration parameters
1616

@@ -33,18 +33,19 @@ GatewayD supports multiple client configurations. Each client in each configurat
3333
```yaml
3434
clients:
3535
default:
36-
network: tcp
37-
address: localhost:5432
38-
tcpKeepAlive: False
39-
tcpKeepAlivePeriod: 30s # duration
40-
receiveChunkSize: 8192
41-
receiveDeadline: 0s # duration, 0ms/0s means no deadline
42-
receiveTimeout: 0s # duration, 0ms/0s means no timeout
43-
sendDeadline: 0s # duration, 0ms/0s means no deadline
44-
dialTimeout: 60s # duration, 0ms/0s means no timeout
45-
# Retry configuration
46-
retries: 3 # 0 means no retry
47-
backoff: 1s # duration
48-
backoffMultiplier: 2.0 # 0 means no backoff
49-
disableBackoffCaps: false
36+
writes:
37+
network: tcp
38+
address: localhost:5432
39+
tcpKeepAlive: False
40+
tcpKeepAlivePeriod: 30s # duration
41+
receiveChunkSize: 8192
42+
receiveDeadline: 0s # duration, 0ms/0s means no deadline
43+
receiveTimeout: 0s # duration, 0ms/0s means no timeout
44+
sendDeadline: 0s # duration, 0ms/0s means no deadline
45+
dialTimeout: 60s # duration, 0ms/0s means no timeout
46+
# Retry configuration
47+
retries: 3 # 0 means no retry
48+
backoff: 1s # duration
49+
backoffMultiplier: 2.0 # 0 means no backoff
50+
disableBackoffCaps: false
5051
```

using-gatewayd/global-configuration/pools.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
last_modified_date: 2024-05-31 20:16:38
2+
last_modified_date: 2024-07-29 17:37:00
33
layout: default
44
title: Pools
55
description: GatewayD pool configuration
@@ -23,5 +23,6 @@ The size of the pool defines the maximum capacity of the pool. Upon start, Gatew
2323
```yaml
2424
pools:
2525
default:
26-
size: 10
26+
writes:
27+
size: 10
2728
```

using-gatewayd/global-configuration/proxies.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
last_modified_date: 2024-05-31 20:16:38
2+
last_modified_date: 2024-07-30 16:34:34
33
layout: default
44
title: Proxies
55
description: GatewayD proxy configuration
@@ -12,7 +12,7 @@ grand_parent: Using GatewayD
1212

1313
The proxy object is used to proxy connections between database clients and servers.
1414

15-
GatewayD supports a fixed proxy that creates a pool with a fixed number of connection to the database server. It honors the pool capacity, and if the number of connections from the clients is more than the capacity, new connections will be rejected.
15+
GatewayD supports multiple proxies, each creating its own pool of connections to the database server. Each proxy pool honors its capacity, and if the number of connections from the clients exceeds the capacity, new connections will be rejected.
1616

1717
The PostgreSQL database expects new connections to authenticate before keeping them connected forever, thus the TCP connections from GatewayD will be timed out and dropped. A health check scheduler is started when creating connections to the database. If there are connections available in the available connections pool after the `healthCheckPeriod` is reached, it will remove and recreate new TCP connections to the database and put them in the pool.
1818

@@ -32,5 +32,6 @@ Each proxy has two pools:
3232
```yaml
3333
proxies:
3434
default:
35-
healthCheckPeriod: 60s # duration
36-
```
35+
writes:
36+
healthCheckPeriod: 60s # duration
37+
```

using-gatewayd/global-configuration/servers.md

+34-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
last_modified_date: 2024-05-31 20:16:38
2+
last_modified_date: 2024-07-30 16:45:29
33
layout: default
44
title: Servers
55
description: GatewayD server configuration
@@ -14,24 +14,46 @@ The server object runs to listen for incoming connections from database clients.
1414

1515
## Configuration parameters
1616

17-
| Name | Type | Default value | Possible values | Description |
18-
| ---------------- | ------- | ------------- | --------------- | ----------------------------------- |
19-
| network | string | tcp | tcp, unix | The network protocol to use |
20-
| address | string | 0.0.0.0:15432 | Valid host:port | The address to listen on |
21-
| enableTicker | boolean | False | True, False | Whether to enable the ticker or not |
22-
| tickInterval | string | 5s | Valid duration | The interval of the ticker |
23-
| enableTLS | boolean | False | True, False | Whether to enable TLS or not |
24-
| certFile | string | | Valid path | The path to the TLS certificate |
25-
| keyFile | string | | Valid path | The path to the TLS key |
26-
| handshakeTimeout | string | 5s | Valid duration | The timeout for TLS handshake |
17+
| Name | Type | Default value | Possible values | Description |
18+
| -------------------------------------- | ------- | ------------- | -------------------------------------------- | --------------------------------------------------------------------------- |
19+
| network | string | tcp | tcp, unix | The network protocol to use |
20+
| address | string | 0.0.0.0:15432 | Valid host:port | The address to listen on |
21+
| enableTicker | boolean | False | True, False | Whether to enable the ticker or not |
22+
| tickInterval | string | 5s | Valid duration | The interval of the ticker |
23+
| enableTLS | boolean | False | True, False | Whether to enable TLS or not |
24+
| certFile | string | | Valid path | The path to the TLS certificate |
25+
| keyFile | string | | Valid path | The path to the TLS key |
26+
| handshakeTimeout | string | 5s | Valid duration | The timeout for TLS handshake |
27+
| loadBalancer | object | | | Configuration for the load balancer |
28+
| loadBalancer.strategy | string | ROUND_ROBIN | ROUND_ROBIN, RANDOM, WEIGHTED_ROUND_ROBIN | The strategy used to distribute connections |
29+
| loadBalancer.consistentHash | object | | | Configuration for consistent hash-based load balancing |
30+
| loadBalancer.consistentHash.useSourceIp | boolean | False | True, False | Whether to use the source IP for consistent hashing |
31+
| loadBalancer.loadBalancingRules | array | | List of rules | Optional configuration for strategies that support rules (e.g., WEIGHTED_ROUND_ROBIN) |
32+
| loadBalancingRules.condition | string | DEFAULT | DEFAULT | Condition for the load balancing rule (currently, only "DEFAULT" is supported) |
33+
| loadBalancingRules.distribution | array | | List of proxyName and weight pairs | Defines the weight distribution for proxies in the load balancing strategy |
34+
| distribution.proxyName | string | | Valid proxy name | Name of the proxy server (e.g., "writes", "reads") |
35+
| distribution.weight | integer | | Positive integer | Weight assigned to a proxy in the load balancing distribution |
2736

28-
## Example configuration
37+
38+
### Example Configuration
2939

3040
```yaml
3141
servers:
3242
default:
3343
network: tcp
3444
address: 0.0.0.0:15432
45+
loadBalancer:
46+
strategy: ROUND_ROBIN # ROUND_ROBIN, RANDOM, WEIGHTED_ROUND_ROBIN
47+
consistentHash:
48+
useSourceIp: true
49+
# Optional configuration for strategies that support rules (e.g., WEIGHTED_ROUND_ROBIN)
50+
# loadBalancingRules:
51+
# - condition: "DEFAULT" # Currently, only the "DEFAULT" condition is supported
52+
# distribution:
53+
# - proxyName: "writes"
54+
# weight: 70
55+
# - proxyName: "reads"
56+
# weight: 30
3557
enableTicker: False
3658
tickInterval: 5s # duration
3759
enableTLS: False

0 commit comments

Comments
 (0)