Skip to content

Commit 6f40518

Browse files
committed
perf(http): reduce maxSockets from 50 to 10 for CLI resource management (Issue #9)
Reduced HTTP/HTTPS agent maxSockets from 50 to 10 for better resource management. Changes: - Updated httpAgent.maxSockets: 50 → 10 - Updated httpsAgent.maxSockets: 50 → 10 - Added explanatory comments about conservative value for CLI tools - Prevents resource exhaustion on user machines - Still allows reasonable parallelism for batch operations Impact: - Lower memory footprint - Reduced system resource usage - Minimal performance impact (CLI rarely needs >10 concurrent connections) Location: src/api/deepl-client.ts:133-147
1 parent 190fa0b commit 6f40518

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5252
- **Performance Benefit**: Avoids expensive database aggregation on every cache write
5353
- Location: `src/storage/cache.ts` (currentSize field, initialize, set, clear, cleanupExpired, evictIfNeeded)
5454

55+
- **Performance Optimization: HTTP Connection Pool Size** - Reduced resource consumption for CLI tool (Issue #9)
56+
- Reduced maxSockets from 50 to 10 for both HTTP and HTTPS agents
57+
- Conservative value prevents resource exhaustion on user machines
58+
- 50 concurrent sockets was excessive for a CLI tool's typical workload
59+
- Still allows reasonable parallelism for batch operations
60+
- Matches maxFreeSockets value for consistency
61+
- **Impact**: Lower memory footprint and reduced system resource usage
62+
- **Performance Trade-off**: Minimal impact on throughput; CLI rarely needs >10 concurrent connections
63+
- Location: `src/api/deepl-client.ts:133-147` (HTTP/HTTPS agent configuration)
64+
5565
### Security
5666
- **Symlink Path Validation** - Prevents directory traversal attacks (Issue #6)
5767
- Rejects symlinks at translate() entry point before processing files

src/api/deepl-client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,18 @@ export class DeepLClient {
130130
'Connection': 'keep-alive',
131131
},
132132
// Enable HTTP keep-alive for better performance in batch operations
133+
// Issue #9: Reduced maxSockets from 50 to 10 for CLI tool resource management
133134
httpAgent: new http.Agent({
134135
keepAlive: true,
135136
keepAliveMsecs: 1000,
136-
maxSockets: 50,
137+
maxSockets: 10, // Conservative value for CLI tool to prevent resource exhaustion
137138
maxFreeSockets: 10,
138139
timeout: options.timeout ?? DEFAULT_TIMEOUT,
139140
}),
140141
httpsAgent: new https.Agent({
141142
keepAlive: true,
142143
keepAliveMsecs: 1000,
143-
maxSockets: 50,
144+
maxSockets: 10, // Conservative value for CLI tool to prevent resource exhaustion
144145
maxFreeSockets: 10,
145146
timeout: options.timeout ?? DEFAULT_TIMEOUT,
146147
}),

0 commit comments

Comments
 (0)