Skip to content

Have table manager accept flags for read/write throughput on inactive tables. #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions chunk/dynamo_table_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import (
)

const (
readLabel = "read"
writeLabel = "write"
minWriteCapacity = 1
readLabel = "read"
writeLabel = "write"
)

var (
Expand Down Expand Up @@ -52,6 +51,8 @@ type TableManagerConfig struct {
MaxChunkAge time.Duration
ProvisionedWriteThroughput int64
ProvisionedReadThroughput int64
InactiveWriteThroughput int64
InactiveReadThroughput int64
}

// RegisterFlags adds the flags required to config this to the given FlagSet
Expand All @@ -62,6 +63,9 @@ func (cfg *TableManagerConfig) RegisterFlags(f *flag.FlagSet) {
f.DurationVar(&cfg.MaxChunkAge, "ingester.max-chunk-age", 12*time.Hour, "Maximum chunk age time before flushing.")
f.Int64Var(&cfg.ProvisionedWriteThroughput, "dynamodb.periodic-table.write-throughput", 3000, "DynamoDB periodic tables write throughput")
f.Int64Var(&cfg.ProvisionedReadThroughput, "dynamodb.periodic-table.read-throughput", 300, "DynamoDB periodic tables read throughput")
f.Int64Var(&cfg.InactiveWriteThroughput, "dynamodb.periodic-table.inactive-write-throughput", 1, "DynamoDB periodic tables write throughput for inactive tables.")
f.Int64Var(&cfg.InactiveReadThroughput, "dynamodb.periodic-table.inactive-read-throughput", 300, "DynamoDB periodic tables read throughput for inactive tables")

cfg.PeriodicTableConfig.RegisterFlags(f)
}

Expand Down Expand Up @@ -173,12 +177,13 @@ func (m *DynamoTableManager) calculateExpectedTables() []tableDescription {
{
legacyTable := tableDescription{
name: m.cfg.DynamoDB.TableName,
provisionedRead: m.cfg.ProvisionedReadThroughput,
provisionedWrite: minWriteCapacity,
provisionedRead: m.cfg.InactiveReadThroughput,
provisionedWrite: m.cfg.InactiveWriteThroughput,
}

// if we are before the switch to periodic table, we need to give this table write throughput
if now < (firstTable*tablePeriodSecs)+gracePeriodSecs+maxChunkAgeSecs {
legacyTable.provisionedRead = m.cfg.ProvisionedReadThroughput
legacyTable.provisionedWrite = m.cfg.ProvisionedWriteThroughput
}
result = append(result, legacyTable)
Expand All @@ -188,12 +193,13 @@ func (m *DynamoTableManager) calculateExpectedTables() []tableDescription {
table := tableDescription{
// Name construction needs to be consistent with chunk_store.bigBuckets
name: m.cfg.TablePrefix + strconv.Itoa(int(i)),
provisionedRead: m.cfg.ProvisionedReadThroughput,
provisionedWrite: minWriteCapacity,
provisionedRead: m.cfg.InactiveReadThroughput,
provisionedWrite: m.cfg.InactiveWriteThroughput,
}

// if now is within table [start - grace, end + grace), then we need some write throughput
if (i*tablePeriodSecs)-gracePeriodSecs <= now && now < (i*tablePeriodSecs)+tablePeriodSecs+gracePeriodSecs+maxChunkAgeSecs {
table.provisionedRead = m.cfg.ProvisionedReadThroughput
table.provisionedWrite = m.cfg.ProvisionedWriteThroughput
}
result = append(result, table)
Expand Down
30 changes: 17 additions & 13 deletions chunk/dynamo_table_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ import (
)

const (
tablePrefix = "cortex_"
tablePeriod = 7 * 24 * time.Hour
gracePeriod = 15 * time.Minute
maxChunkAge = 12 * time.Hour
write = 200
read = 100
tablePrefix = "cortex_"
tablePeriod = 7 * 24 * time.Hour
gracePeriod = 15 * time.Minute
maxChunkAge = 12 * time.Hour
inactiveWrite = 1
inactiveRead = 2
write = 200
read = 100
)

func TestDynamoTableManager(t *testing.T) {
Expand All @@ -42,6 +44,8 @@ func TestDynamoTableManager(t *testing.T) {
MaxChunkAge: maxChunkAge,
ProvisionedWriteThroughput: write,
ProvisionedReadThroughput: read,
InactiveWriteThroughput: inactiveWrite,
InactiveReadThroughput: inactiveRead,
}
tableManager, err := NewDynamoTableManager(cfg)
if err != nil {
Expand Down Expand Up @@ -93,7 +97,7 @@ func TestDynamoTableManager(t *testing.T) {
"Move forward by max chunk age + grace period",
time.Unix(0, 0).Add(maxChunkAge).Add(gracePeriod),
[]tableDescription{
{name: "", provisionedRead: read, provisionedWrite: minWriteCapacity},
{name: "", provisionedRead: inactiveRead, provisionedWrite: inactiveWrite},
{name: tablePrefix + "0", provisionedRead: read, provisionedWrite: write},
},
)
Expand All @@ -103,7 +107,7 @@ func TestDynamoTableManager(t *testing.T) {
"Move forward by table period - grace period",
time.Unix(0, 0).Add(tablePeriod).Add(-gracePeriod),
[]tableDescription{
{name: "", provisionedRead: read, provisionedWrite: minWriteCapacity},
{name: "", provisionedRead: inactiveRead, provisionedWrite: inactiveWrite},
{name: tablePrefix + "0", provisionedRead: read, provisionedWrite: write},
{name: tablePrefix + "1", provisionedRead: read, provisionedWrite: write},
},
Expand All @@ -114,7 +118,7 @@ func TestDynamoTableManager(t *testing.T) {
"Move forward by table period + grace period",
time.Unix(0, 0).Add(tablePeriod).Add(gracePeriod),
[]tableDescription{
{name: "", provisionedRead: read, provisionedWrite: minWriteCapacity},
{name: "", provisionedRead: inactiveRead, provisionedWrite: inactiveWrite},
{name: tablePrefix + "0", provisionedRead: read, provisionedWrite: write},
{name: tablePrefix + "1", provisionedRead: read, provisionedWrite: write},
},
Expand All @@ -125,8 +129,8 @@ func TestDynamoTableManager(t *testing.T) {
"Move forward by table period + max chunk age + grace period",
time.Unix(0, 0).Add(tablePeriod).Add(maxChunkAge).Add(gracePeriod),
[]tableDescription{
{name: "", provisionedRead: read, provisionedWrite: minWriteCapacity},
{name: tablePrefix + "0", provisionedRead: read, provisionedWrite: minWriteCapacity},
{name: "", provisionedRead: inactiveRead, provisionedWrite: inactiveWrite},
{name: tablePrefix + "0", provisionedRead: inactiveRead, provisionedWrite: inactiveWrite},
{name: tablePrefix + "1", provisionedRead: read, provisionedWrite: write},
},
)
Expand All @@ -136,8 +140,8 @@ func TestDynamoTableManager(t *testing.T) {
"Nothing changed",
time.Unix(0, 0).Add(tablePeriod).Add(maxChunkAge).Add(gracePeriod),
[]tableDescription{
{name: "", provisionedRead: read, provisionedWrite: minWriteCapacity},
{name: tablePrefix + "0", provisionedRead: read, provisionedWrite: minWriteCapacity},
{name: "", provisionedRead: inactiveRead, provisionedWrite: inactiveWrite},
{name: tablePrefix + "0", provisionedRead: inactiveRead, provisionedWrite: inactiveWrite},
{name: tablePrefix + "1", provisionedRead: read, provisionedWrite: write},
},
)
Expand Down