Skip to main content

Human-readable Byte Configuration Reference

This page documents configuration properties related to bytes.

These properties can be configured through 2 ways:

  1. a simple number in bytes
  2. a number with a unit suffix

A number in bytes

Given that cache size is 3G, there's a configuration as below

# 3G bytes = 3_000_000_000 bytes
druid.cache.sizeInBytes=3000000000

A number with a unit suffix

When you have to put a large number for some configuration as above, it is easy to make a mistake such as extra or missing 0s. Druid supports a better way, a number with a unit suffix.

Given a disk of 1T, the configuration can be

druid.segmentCache.locations=[{"path":"/segment-cache-00","maxSize":"1t"},{"path":"/segment-cache-01","maxSize":"1200g"}]

Note: in above example, both 1t and 1T are acceptable since it's case-insensitive. Also, only integers are valid as the number part. For example, you can't replace 1200g with 1.2t.

Supported Units

In the world of computer, a unit like K is ambiguous. It means 1000 or 1024 in different contexts, for more information please see Here.

To make it clear, the base of units are defined in Druid as below

UnitDescriptionBase
KKilo Decimal Byte1_000
MMega Decimal Byte1_000_000
GGiga Decimal Byte1_000_000_000
TTera Decimal Byte1_000_000_000_000
PPeta Decimal Byte1_000_000_000_000_000
KiKilo Binary Byte1024
MiMega Binary Byte1024 * 1024
GiGiga Binary Byte1024 1024 1024
TiTera Binary Byte1024 1024 1024 * 1024
PiPeta Binary Byte1024 1024 1024 1024 1024
KiBKilo Binary Byte1024
MiBMega Binary Byte1024 * 1024
GiBGiga Binary Byte1024 1024 1024
TiBTera Binary Byte1024 1024 1024 * 1024
PiBPeta Binary Byte1024 1024 1024 1024 1024

Unit is case-insensitive. k, kib, ki, KiB, Ki, kiB are all acceptable.

Here are some examples

# 1G bytes = 1_000_000_000 bytes
druid.cache.sizeInBytes=1g
# 256MiB bytes = 256 * 1024 * 1024 bytes
druid.cache.sizeInBytes=256MiB
# 256Mi = 256MiB = 256 * 1024 * 1024 bytes
druid.cache.sizeInBytes=256Mi