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
- Automatic lock release when guard is dropped (via background cleanup tasks)
119
-
120
-
**Note**: PostgreSQL locks require the same PostgreSQL instance used for KV storage. Connection pool is shared between both uses.
112
+
**Note**: PostgreSQL locks share the connection pool with KV storage. Ensure sufficient pool size for concurrent operations. See [DEVELOPMENT.md](DEVELOPMENT.md) for implementation details.
121
113
122
114
### Connection Pool Sizing
123
115
124
-
The `POSTGRES_MAX_CONNECTIONS` setting controls the maximum number of concurrent database connections from a single s3dedup instance. This **single pool** is shared between KV storage operations and lock management.
125
-
126
-
**How to Choose Pool Size:**
127
-
128
-
```
129
-
Pool Size = (Concurrent Requests × 1.5) + Lock Overhead
- Reserve connections for maintenance, monitoring, backups
158
-
- Example: PostgreSQL with 200 max_connections:
159
-
- Reserve 10 for maintenance
160
-
- If 3 s3dedup instances: (200 - 10) / 3 ≈ 63 per instance
161
-
162
-
4.**Memory Usage Per Connection**
163
-
- Each connection uses ~5-10 MB of memory
164
-
- Pool size 50 = ~250-500 MB per instance
165
-
- Monitor actual usage and adjust accordingly
166
-
167
-
**Example Configurations:**
168
-
169
-
**Development (1 instance, low throughput):**
170
-
```json
171
-
"postgres": {
172
-
"pool_size": 10
173
-
}
174
-
```
175
-
176
-
**Production (3 instances, medium throughput):**
177
-
```json
178
-
"postgres": {
179
-
"pool_size": 30
180
-
}
181
-
```
182
-
With PostgreSQL `max_connections = 100`:
183
-
- 3 × 30 = 90 connections (10 reserved)
184
-
185
-
**High-Availability (5 instances, high throughput with PostgreSQL max_connections = 200):**
186
-
```json
187
-
"postgres": {
188
-
"pool_size": 35
189
-
}
190
-
```
191
-
- 5 × 35 = 175 connections (25 reserved for other operations)
116
+
The `POSTGRES_MAX_CONNECTIONS` setting controls the maximum number of concurrent database connections. This pool is shared between KV storage operations and lock management.
192
117
193
-
**Monitoring and Tuning:**
118
+
**Quick Start Recommendations:**
119
+
-**Development**: `POSTGRES_MAX_CONNECTIONS=10`
120
+
-**Small Production (1-3 instances)**: `POSTGRES_MAX_CONNECTIONS=20-30`
121
+
-**Large Production (5+ instances)**: `POSTGRES_MAX_CONNECTIONS=50-100`
194
122
195
-
Monitor these metrics to optimize pool size:
196
-
197
-
1.**Connection Utilization**: Check if connections are frequently exhausted
198
-
```sql
199
-
SELECTcount(*) FROM pg_stat_activity WHERE datname ='s3dedup';
200
-
```
201
-
202
-
2.**Lock Wait Times**: Monitor if operations wait for available connections
203
-
3.**Memory Usage**: Watch instance memory as pool size increases
204
-
205
-
**Scaling Strategy:**
206
-
207
-
-**Start Conservative**: Begin with pool_size = 10-20
208
-
-**Monitor Usage**: Track connection utilization over 1-2 weeks
209
-
-**Increase Gradually**: Increment by 10-20 when you see high utilization
210
-
-**Scale Horizontally**: Instead of very large pools (>100), use more instances with moderate pools
123
+
For detailed pool sizing guidance, monitoring strategies, and tuning considerations, see [DEVELOPMENT.md](DEVELOPMENT.md#connection-pool-sizing).
0 commit comments