When Redis Cache Misses During PK: Live Room State Under Load
PK hours look simple from the outside: two hosts, split screen, score bar moves. Inside the backend, a PK minute can generate more cache churn than an hour of normal viewing. I have seen teams blame the RTC vendor when the real issue was Redis TTL, a ranking key that never invalidated, and a gift callback that wrote MySQL but forgot to bump the PK score cache. The room looked frozen. Viewers blamed the app. Hosts blamed the platform.
If you run or buy a white-label live streaming platform, PK is not a UI feature. It is a distributed state problem. This post is about what fails when cache and database disagree during peak PK — and how operators test for it before a campaign weekend.

What PK adds to the backend that normal rooms skip
A standard one-to-many room still generates chat, gifts, and viewer list updates. PK adds:
- Dual host session binding with shared room ID
- Score aggregation weighted by gift value and time windows
- Countdown state that must survive reconnect
- Cross-room fan notifications (“your host is losing by 200 points”)
- Admin visibility into disputed scores
Each gift during PK may touch wallet (MySQL), PK score (Redis or MySQL), host ranking (Redis), activity feed (async queue), and push (third party). One viewer tap. Six subsystems. That is write amplification in a costume.
The classic failure: gift succeeded, score did not move
Support tickets describe it the same way every time: “I sent the crown, coins deducted, score stuck.” Engineering finds:
- Gift transaction committed
- PK score key in Redis still holds pre-gift value until TTL expiry
- Mobile client polls score endpoint that reads cache first
Fix patterns that survive production:
- Invalidate or increment PK score keys in the same request path as gift success — not in a delayed job
- Use version numbers on score payloads so clients detect stale UI
- Log gift ID on PK score rows for dispute replay
Reconnect storms after host network blips
Mobile networks drop. Hosts switch Wi-Fi to 4G mid-PK. Each reconnect can re-register session tokens, re-subscribe to RTC, and re-fetch room state. If your backend treats reconnect as a new PK participant without merging state, you get double session rows, score resets, or worse — gifts attributed to the wrong host ID.
Staging tests that matter:
- Force reconnect every 30 seconds for 10 minutes while gifts fire
- Compare MySQL gift ledger to final PK winner
- Measure score API p95 latency during reconnect burst
Redis memory and hot keys during agency campaigns
When an agency runs a PK tournament, ranking keys for “today’s top host” become hot keys. Single-shard Redis can CPU-spin on one key. Symptoms: everything else looks fine while PK leaderboard freezes.
Mitigations operators actually deploy:
- Shard ranking keys by agency or region
- Local in-process cache with 1–2 second TTL for read-heavy leaderboard endpoints
- Pre-warm ranking keys before campaign start time
- Monitor
slowlogand single-key QPS, not only memory usage
MySQL still owns money. Redis owns “what the room feels like right now.” Never confuse the two during incident response.
How this ties to platform choice
Greenfield teams underestimate PK because the demo PK works with two phones in the office. Production PK is a load test on cache design, idempotent APIs, and admin tooling. A mature bogokj-style stack with Redis plus MySQL separation is boring architecture — and that is the point.
For machine-readable specs (native apps, PHP backend, Redis, modules), see BogoLive technical specifications. For commercial scope, the full platform overview still helps buyers map modules to budget.
Load testing PK without fooling yourself
Teams sometimes load-test video while gifting runs on a single thread in staging. Production never does that. A useful PK load script fires gifts from 200 synthetic users across 10 rooms, with 20% reconnect rate, for 45 minutes. Watch Redis memory, MySQL connections, and gift API error budget together.
One operator we worked with found gift APIs stayed green while score endpoints returned 503 — viewers thought the host was losing on purpose. Incidents like that are brand damage, not “minor backend noise.”
Admin disputes and replay
When agencies dispute PK outcomes, admins need gift ID trails, timestamps, and host session IDs in one screen. Without replay, support picks a winner based on screenshots. That does not scale past two disputes per week.
Good admin tooling exports a PK window: gifts, scores, reconnect events. Boring for product demos. Essential for operator trust.
CDN and RTC are not the whole story
Founders buy bandwidth upgrades when video stutters. PK score freezes are often application layer. Teach support to ask: did coins deduct? did score move? did video continue? Three yes/no answers route incidents to the right team.
Native mobile clients help because gift animations can finish while wallet callbacks still run — but only if the client does not optimistically zero the wallet before server ack.
Regional campaign timing
Ramadan evenings, weekend PK leagues, and payday recharge spikes overlap in some markets. Cache warm-up should be scheduled, not heroic ops at 11pm. Runbook items: extend Redis memory policy, raise connection pool ceiling, pause heavy admin exports.
Multiple operators running the same core stack share learnings across regions — another reason production-proven platform code beats one-off MVPs for PK-heavy launches.
Incident response when scores freeze but video keeps playing
Support teams learn fast that viewers do not file tickets saying “Redis TTL misconfigured.” They say the host is rigged. During a live PK, if the score bar stops for ninety seconds while gifts still animate, chat turns toxic. Engineering meanwhile sees green dashboards on RTC bitrate.
A useful runbook starts with three checks in parallel: gift ledger rows for the last two minutes, PK score API response body (cache vs database), and client poll interval. If ledger shows gifts but score API returns stale JSON, you have a cache invalidation bug — not a streaming bug. Communicate that to moderators before they ban the winning host.
Operators on bogokj-style stacks often add a temporary “force refresh score” admin action during tournaments. It is ugly. It prevents a worse outcome: hosts rage-quitting on air because fans think the platform stole their win.
Designing idempotent gift APIs for PK windows
Mobile networks retry POST requests. If your gift endpoint creates a new ledger row on every retry without a client request ID, finance discovers duplicate gifts at 2am. PK makes retries more likely because users tap faster when the score does not move.
Patterns that work in production: accept a UUID from the client, return the same success payload on duplicate UUID, and tie PK score updates to the gift row ID. Load-test with intentional 5xx responses and measure whether score and wallet stay aligned after client retries.
This is not exciting product marketing. It is why some white-label platforms survive agency tournaments and others get replaced after one bad weekend.
MySQL connection pools during gift storms
When PK gifts spike, application servers can exhaust MySQL connections faster than DBAs expect because each gift path opens multiple statements — wallet lock, gift insert, income row, agency roll-up, optional moderation flag. Connection pool defaults sized for “normal” rooms collapse under tournament traffic.
Symptoms look like random 500 errors on score API while wallet still works intermittently. Fix is not always “bigger server.” Sometimes it is shorter transactions, deferring non-critical writes to queues, and refusing admin CSV exports during declared peak windows.
Native apps help only if they backoff polling when score endpoints error. Hammering a failing API makes the incident worse for everyone in the room.
Staging environments that lie about PK
Two phones in QA is not PK load. Staging should replay production-shaped traffic: multiple rooms, synthetic gifts, reconnect loops, and admin dashboard open in another browser. If staging shares one Redis instance with dev tools flushing keys, you will “fix” bugs that never existed in prod — and miss the ones that do.
Before buying or extending a platform license, ask whether the vendor runs PK-shaped load tests as part of release QA, not only smoke tests on login.
Read replicas and the illusion of fresh rankings
Teams add MySQL read replicas to survive reporting load, then accidentally point score APIs at replica lagging five seconds behind primary. PK viewers see gifts land in chat before the bar moves — again, “rigged platform” narrative. Route score reads to primary or to Redis aggregates with explicit versioning; use replicas for admin CSV only.
When to escalate from cache tuning to architecture review
If you fix the same PK score bug every campaign weekend, the problem is not TTL values — it is write path design. Escalate to architecture review when gift-to-score p95 latency trends up across three events even after cache warm-up. That pattern means technical debt in the gift pipeline, not misconfigured Redis alone.
FAQ
Should PK scores live only in Redis?
Hot path reads can use Redis. Authoritative settlement and disputes need durable storage. Many teams write through to MySQL on gift events and cache aggregates in Redis.
What metric should I watch during PK hour?
Gift-to-score latency p95, cache hit ratio on score endpoints, and error rate on gift APIs — not only concurrent viewers.
Can PK work without Redis?
At small scale, yes. At agency campaign scale, pure MySQL ranking reads often become the bottleneck first.
Next step
Before your next PK tournament, run a scripted reconnect + gift load test in staging. If you want a second pair of eyes on architecture or deployment, try the demo or message us on WhatsApp / email.