tree: 09862666535d0a303cb3771cc6b666926c08a3d1 [path history] [tgz]
  1. src/
  2. BUILD.bazel
  3. pom.xml
  4. README.md
  5. tiered_storage_arch.png
tieredstore/README.md

Tiered storage for RocketMQ (Technical preview)

RocketMQ tiered storage allows users to offload message data from the local disk to other cheaper and larger storage mediums. So that users can extend the message reserve time at a lower cost. And different topics can flexibly specify different TTL as needed.

This article is a cookbook for RocketMQ tiered storage.

Architecture

Tiered storage architecture

Quick start

Use the following steps to easily use tiered storage

  1. Change messageStorePlugIn to org.apache.rocketmq.tieredstore.TieredMessageStore in your broker.conf.
  2. Configure your backend service provider. change tieredBackendServiceProvider to your storage medium implement. We give a default implement: POSIX provider, and you need to change tieredStoreFilePath to the mount point of storage medium for tiered storage.
  3. Start the broker and enjoy!

Configuration

The following are some core configurations, for more details, see TieredMessageStoreConfig

ConfigurationDefault valueUnitFunction
messageStorePlugInSet to org.apache.rocketmq.tieredstore.TieredMessageStore to use tiered storage
tieredMetadataServiceProviderorg.apache.rocketmq.tieredstore.metadata.DefaultMetadataStoreSelect your metadata provider
tieredBackendServiceProviderorg.apache.rocketmq.tieredstore.provider.PosixFileSegmentSelect your backend service provider
tieredStoreFilePathSelect the directory using for tiered storage, only for POSIX provider.
tieredStorageLevelNOT_IN_DISKThe options are DISABLE, NOT_IN_DISK, NOT_IN_MEM, FORCE
tieredStoreFileReservedTime72hourDefault topic TTL in tiered storage
tieredStoreGroupCommitCount2500The number of messages that trigger one batch transfer
tieredStoreGroupCommitSize33554432byteThe size of messages that trigger one batch transfer, 32M by default
tieredStoreMaxGroupCommitCount10000The maximum number of messages waiting to be transfered per queue
readAheadCacheExpireDuration1000millisecondRead-ahead cache expiration time
readAheadCacheSizeThresholdRate0.3The maximum heap space occupied by the read-ahead cache

Metrics

Tiered storage provides some useful metrics, see RIP-46 for details.

TypeNameUnit
Histogramrocketmq_tiered_store_api_latencymilliseconds
Histogramrocketmq_tiered_store_provider_rpc_latencymilliseconds
Histogramrocketmq_tiered_store_provider_upload_bytesbyte
Histogramrocketmq_tiered_store_provider_download_bytesbyte
Gaugerocketmq_tiered_store_dispatch_behind
Gaugerocketmq_tiered_store_dispatch_latencybyte
Counterrocketmq_tiered_store_messages_dispatch_total
Counterrocketmq_tiered_store_messages_out_total
Counterrocketmq_tiered_store_get_message_fallback_total
Gaugerocketmq_tiered_store_read_ahead_cache_count
Gaugerocketmq_tiered_store_read_ahead_cache_bytesbyte
Counterrocketmq_tiered_store_read_ahead_cache_access_total
Counterrocketmq_tiered_store_read_ahead_cache_hit_total
Gaugerocketmq_storage_message_reserve_timemilliseconds

How to contribute

We need community participation to add more backend service providers for tiered storage. PosixFileSegment, the implementation provided by default is just an example. People who want to contribute can follow it to implement their own providers, such as S3FileSegment, OSSFileSegment, and MinIOFileSegment. Here are some guidelines:

  1. Extend FileSegment and implement the methods of FileSegmentProvider interface.
  2. Record metrics where appropriate. See rocketmq_tiered_store_provider_rpc_latency, rocketmq_tiered_store_provider_upload_bytes, and rocketmq_tiered_store_provider_download_bytes
  3. No need to maintain your own cache and avoid polluting the page cache. It is already having the read-ahead cache.