Retain Hot or Warm Data in Memory to Enhance Read Performance

In PostgreSQL, shared_buffers is a configuration parameter that determines the amount of memory dedicated to caching data blocks in shared memory. This is crucial for PostgreSQL’s performance as it reduces disk I/O by keeping frequently accessed data in memory.

Within the realm of YugabyteDB, the conventional approach to utilizing the shared_buffers mechanism differs significantly. This stems from the fact that YugabyteDB operates without relying on the PostgreSQL-level buffer cache.

Instead, caching in YugabyteDB takes place on the TServer process, which is a part of YugabyteDB’s distributed architecture. The TServer process has its own mechanisms for managing memory and caching, which are designed to work efficiently across a distributed system.

On the TServer, the block cache, depicted as BlockBasedTable on the Memory Breakdown page of the TServer UI (http://IP:7000/mem-trackers), consumes the most memory within tserver. Its purpose is to retain hot or warm data in memory, enhancing read performance. 

By default, the configuration (db_block_cache_size_percentage) allocates 50% of memory, shared among all RocksDB instances on the server.

We can check the default value for the block cach size percentage from the command line like this:

				
					# yb-tserver --help | sed -n -e '/-db_block_cache_size_percentage/,/default:/ p'
    -db_block_cache_size_percentage (Default percentage of total available
      memory to use as block cache size, if not asking for a raw number,
      through FLAGS_db_block_cache_size_bytes. Defaults to -3 (use default
      percentage as defined by master or tserver).) type: int32 default: -3
				
			

If a precise allocation is needed, you can set db_block_cache_size_bytes instead.

We can check the default value for the block cach size from the command line like this:

				
					# yb-tserver --help | sed -n -e '/-db_block_cache_size_bytes/,/default:/ p'
    -db_block_cache_size_bytes (Size of RocksDB block cache (in bytes). This
      defaults to -1 for system auto-generated default, which would use
      FLAGS_db_block_cache_size_percentage to select a percentage of the total
      memory as the default size for the shared block cache. Value of -2
      disables block cache.) type: int64 default: -1
				
			

Should you notice a high block cache miss rate via the Cache Hit & Miss page in YugabyteDB Anywhere, it’s advisable to consider augmenting the block cache setting.

Have Fun!

At a park in Knoxville, TN, there wasn't much water here to keep out of, so what was the danger?