From 5bbe9866563af5fd3077a74b60cb9df9d9db82e4 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sun, 21 Jun 2026 02:48:35 +0100 Subject: [PATCH] fix(rps): count cache-served requests toward current RPS RecordRequest() only ran inside proxyTheRequest, but cache hits return from handleCaching before reaching it. As a result the dashboard's current RPS read 0 whenever traffic was served from cache (e.g. a repeated query at 100% hit rate). Record the request on the cache-hit branch too; misses and proxied/GET requests still record in proxyTheRequest, so there is no double counting. Verified: 100% cache-hit load now reports ~16-20k req/s instead of a flat 0. --- server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server.go b/server.go index 16b47f2..0126c77 100644 --- a/server.go +++ b/server.go @@ -357,6 +357,13 @@ func handleCaching(c *fiber.Ctx, parsedResult *parseGraphQLQueryResult, userID, // Try to get from cache if cachedResponse := libpack_cache.CacheLookup(calculatedQueryHash); cachedResponse != nil { + // Count cache-served requests toward RPS too. Cache hits return here + // without reaching proxyTheRequest (where misses/proxied requests are + // recorded), so without this the dashboard's current RPS reads 0 + // whenever traffic is served from cache. + if rpsTracker := GetRPSTracker(); rpsTracker != nil { + rpsTracker.RecordRequest() + } cfg.Monitoring.Increment(libpack_monitoring.MetricsCacheHit, nil) c.Set("X-Cache-Hit", "true") c.Set("Content-Type", "application/json")