-
-
Couldn't load subscription status.
- Fork 21.3k
Description
The compileTrust() function in Express has severe performance issues when processing large IP lists, causing startup delays of 2+ seconds for applications with 1M+ trusted IPs.
Performance Impact
| IP Count | Processing Time | Startup Delay |
|---|---|---|
| 10,000 | 33ms | 0.03s |
| 100,000 | 213ms | 0.21s |
| 500,000 | 1,019ms | 1.02s |
| 1,000,000 | 2,365ms | 2.37s |
Real-World Scenarios Affected
- CDNs: 100K+ IPs → 213ms startup delay
- Large Enterprises: 500K+ IPs → 1+ second delay
- Cloud Providers: 1M+ IPs → 2.3+ second delay
This impacts:
- Application startup time
- Server restart time
- Container startup time
- Cold starts in serverless environments
Memory Usage
Large IP lists also consume significant memory:
| IP Count | String Size | Heap Increase | Ratio |
|---|---|---|---|
| 10,000 | 0.10 MB | 3.24 MB | 33.94x |
| 100,000 | 0.95 MB | 34.18 MB | 35.84x |
| 500,000 | 4.77 MB | 149.93 MB | 31.44x |
Related Issues
This performance issue was initially reported in #6611, but that issue was based on a misunderstanding of how compileTrust() works. The reporter expected it to return an array of IPs, but it actually returns a predicate function for checking if an IP is trusted.
The real issue is the performance bottleneck, not the API behavior.
Priority
High - This affects production applications with large trust lists, causing significant startup delays and poor user experience.