Using Channels

Channel Usage

Channels are the IO threads used by the MicroStream storage engine. A single channel represents the unity of a thread, a storage directory and cached data. Increasing the number of channels means to run more IO threads.

The channel count is an important configuration value that impacts to IO performance.

Channel Configuration

For the channel configuration the following configuration properties are available:

Property Description

channel-count

The number of channels that MicroStream will use. Must be 2^n

channel-directory-prefix

The channel directory will be prefix+channelNumber e.g. "ch_0" if prefix is "ch_"

data-file-prefix

Default is "channel_"

data-file-suffix

Default is ".dat"

Channel file size configuration is done by the the Storage Data File Evaluator.

They can be set by microstream-storage-embedded-configuration API:

Java
EmbeddedStorageManager storageManager = EmbeddedStorageConfigurationBuilder.New()
	.setChannelCount(4)
	.setChannelDirectoryPrefix("channel_")
	.setDataFilePrefix("channel_")
	.setDataFileSuffix(".bin")
	.createEmbeddedStorageFoundation()
	.createEmbeddedStorageManager();
XML
<properties>
	<property name="channel-count" value="4" />
	<property name="channel-directory-prefix" value="channel_" />
	<property name="data-file-prefix value="channel_" />
	<property name="data-file-suffix" value=".dat" />
</properties>
INI
channel-count = 4
channel-directory-prefix = prefix
data-file-prefix = channel_
data-file-suffix = .dat

Or by setting a StorageFileProvider using the EmbeddedStorageFoundation factory

NioFileSystem          fileSystem = NioFileSystem.New();
EmbeddedStorageManager storage    = EmbeddedStorage.Foundation(
	Storage.ConfigurationBuilder()
		.setChannelCountProvider(Storage.ChannelCountProvider(4))
		.setStorageFileProvider(
			StorageLiveFileProvider.Builder()
				.setDirectory(fileSystem.ensureDirectoryPath("storage"))
				.createFileProvider()
		)
		.createConfiguration()
)
.start();

See also: Configuration