This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # PR #1136 - CRITICAL Performance Issues | |
| ## Problem Statement | |
| - Connections increased 4-5x | |
| - Hit rate only 65% (expected: 95%+) | |
| - Cache latency 80ms (expected: microseconds) | |
| ## Root Causes Found | |
| ### 🔥 CRITICAL #1: Async Cache Update (lines 355-358) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- a/pkg/redisconn/generic_swr_cache.go | |
| +++ b/pkg/redisconn/generic_swr_cache.go | |
| @@ -213,10 +213,9 @@ func (c *GenericSWRCache) GetBulk(keys []string) (results map[string]*GenericCac | |
| } | |
| // Check if entry is invalid (> InvalidAfterSeconds) | |
| if !entry.IsValid(invalidAfter) { | |
| // Invalid entries are treated as missing - must fetch from Redis | |
| missing = append(missing, key) | |
| - misses++ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // File: pkg/redisconn/generic_swr_cache.go | |
| // Surgical change: Add memory breakdown metrics by cache state | |
| // In reportDataFreshness method (around line 808), REPLACE entire function: | |
| func (c *GenericSWRCache) reportDataFreshness() { | |
| now := time.Now() | |
| staleThreshold := time.Duration(c.config.StaleAfterSeconds) * time.Second | |
| invalidThreshold := time.Duration(c.config.InvalidAfterSeconds) * time.Second | |
| zombieThreshold := 5 * time.Minute |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // File: app/config/config.go | |
| // Changes: Add InvalidAfterSeconds field, adjust StaleAfterSeconds default | |
| type GenericCache struct { | |
| MaxMemoryMB int `envconfig:"CACHE_MAX_MEMORY_MB" default:"300"` | |
| // StaleAfterSeconds: Time after which cached data is stale (served instantly, queued for refresh) | |
| // Default: 5 seconds | |
| StaleAfterSeconds int `envconfig:"CACHE_STALE_AFTER_SECONDS" default:"5"` |