Add HTTP Connection Pool Configuration Support
The default Go HTTP client has MaxIdleConnsPerHost: 2, which is insufficient for microservices making frequent requests to the same host. This causes:
- Connection pool exhaustion errors:
"http: putIdleConn: too many idle connections for host" - Increased latency: Connection establishment time increases from 4.5ms to 13.6ms (3x slower)
- Poor connection reuse, leading to unnecessary connection overhead
Suggested Solution
Add configurable HTTP connection pool settings to gofr's HTTP service initialization, allowing users to customize:
MaxIdleConns: Maximum idle connections across all hostsMaxIdleConnsPerHost: Maximum idle connections per host (critical setting)IdleConnTimeout: How long to keep idle connections
Proposed Changes
- Add HTTP connection pool configuration options to
App.AddHTTPService()method - Apply settings to the HTTP client's transport used by gofr's HTTP services
Benefits
- Eliminates connection pool exhaustion errors
- Improves performance for high-frequency inter-service calls
- Backward compatible
Configuration
Allow configuration via:
- Programmatic API: Optional parameters to
AddHTTPService()
@aryanmehrotra Ill take up this issue and will raise a PR soon!
Hi @ish1416 since the issue is triage phase we need to decide if we want to support this.
@aryanmehrotra I have raised a PR which supports this!
@ish1416 Sure assigned the issue to you. We will review the PR shortly.
@Umang01-hash Why do package unit testing failing?
@ish1416 The Default MQTT Broker we use to connect is giving some connection issue. Don;t worry we will fix it soon. You can work on your issue and once it get fixed your pipeline will also pass.
@Umang01-hash Okay Thanks
hey @Umang01-hash @ish1416 is this fixed or can I work on this ?
hey @Umang01-hash is this issue been solved? If not, Can I work on it?