Kong Gateway

Memory Cache Undersizing

warning
Resource ContentionUpdated Sep 7, 2025

Kong's default mem_cache_size of 128MB is insufficient for production, causing excessive database queries for configuration lookups. Real deployments with 10,000+ routes and complex regex patterns require significantly more memory than documented.

How to detect:

Monitor Kong memory usage and database query rate for configuration lookups. If memory usage grows steadily or Kong repeatedly queries database for route/service config, cache is too small. Database connection pool saturation combined with high memory usage indicates cache thrashing.

Recommended action:

Set mem_cache_size to 50% of available RAM (not the default 128MB). For workers with 16GB RAM, allocate 8GB to cache. Monitor entity count and adjust accordingly—10,000 routes with regex patterns need substantially more than 500 simple routes. Track cache hit ratio to validate sizing.