Eliminating Offline Shop Database Bottlenecks
Querying MySQL directly with wildcard LIKE filters whenever players open Shop Search causes severe InnoDB lock contention under launch-day traffic. Scaling smoothly past thousands of concurrent shops requires combining tuned MySQL 8.0 parameters with an in-memory P2P cache.
1. Recommended my.cnf InnoDB Baseline
[mysqld]
innodb_buffer_pool_size = 4G
innodb_buffer_pool_instances = 4
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
max_connections = 500
table_open_cache = 4096
2. In-Memory Search Index + Atomic DB Cache
- Serve Shop Search filters from RAM-indexed shop snapshots on the game/P2P layer rather than hitting disk tables on every keystroke.
- Route item purchases and safe-box gold withdrawals through atomic single-owner validation inside the
dbcache to eliminate race conditions and duplication bugs. - Offload audit logs into asynchronous batch queues so combat and market ticks never stall waiting on disk flushes.
A well-tuned InnoDB buffer pool paired with P2P memory caching keeps market search latency sub-millisecond even at peak online concurrency.