precreator

package
v1.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2017 License: MIT Imports: 6 Imported by: 0

README

Shard Precreation

During normal operation when InfluxDB receives time-series data, it writes the data to files known as shards. Each shard only contains data for a specific range of time. Therefore, before data can be accepted by the system, the shards must exist and InfluxDB always checks that the required shards exist for every incoming data point. If the required shards do not exist, InfluxDB will create those shards. Because this requires a cluster to reach consensus, the process is not instantaneous and can temporarily impact write-throughput.

Since almost all time-series data is written sequentially in time, the system has an excellent idea of the timestamps of future data. Shard precreation takes advantage of this fact by creating required shards ahead of time, thereby ensuring the required shards exist by the time new time-series data actually arrives. Write-throughput is therefore not affected when data is first received for a range of time that would normally trigger shard creation.

Note that the shard-existence check must remain in place in the code, even with shard precreation. This is because while most data is written sequentially in time, this is not always the case. Data may be written with timestamps in the past, or farther in the future than shard precreation handles.

Configuration

Shard precreation can be disabled if necessary, though this is not recommended. If it is disabled, then shards will be only be created when explicitly needed.

The interval between runs of the shard precreation service, as well as the time-in-advance the shards are created, are also configurable. The defaults should work for most deployments.

Documentation

Overview

Package precreator provides the shard precreation service.

Index

Constants

View Source
const (
	// DefaultCheckInterval is the shard precreation check time if none is specified.
	DefaultCheckInterval = 10 * time.Minute

	// DefaultAdvancePeriod is the default period ahead of the endtime of a shard group
	// that its successor group is created.
	DefaultAdvancePeriod = 30 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled       bool          `toml:"enabled"`
	CheckInterval toml.Duration `toml:"check-interval"`
	AdvancePeriod toml.Duration `toml:"advance-period"`
}

Config represents the configuration for shard precreation.

func NewConfig

func NewConfig() Config

NewConfig returns a new Config with defaults.

func (Config) Validate added in v1.2.0

func (c Config) Validate() error

Validate returns an error if the Config is invalid.

type Service

type Service struct {
	Logger zap.Logger

	MetaClient interface {
		PrecreateShardGroups(now, cutoff time.Time) error
	}
	// contains filtered or unexported fields
}

Service manages the shard precreation service.

func NewService

func NewService(c Config) (*Service, error)

NewService returns an instance of the precreation service.

func (*Service) Close

func (s *Service) Close() error

Close stops the precreation service.

func (*Service) Open

func (s *Service) Open() error

Open starts the precreation service.

func (*Service) WithLogger added in v1.2.0

func (s *Service) WithLogger(log zap.Logger)

WithLogger sets the logger for the service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL