Automatically place servers using learned resource capacity
This commit is contained in:
@@ -40,6 +40,25 @@ export function ensureHostSchema(handle: Database.Database): void {
|
||||
PRIMARY KEY(host_id,bind_address,protocol,port)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS ec_host_ports_instance ON ec_host_ports(instance_id);
|
||||
CREATE TABLE IF NOT EXISTS ec_host_resource_samples (
|
||||
host_id TEXT NOT NULL REFERENCES ec_hosts(id), sampled_at TEXT NOT NULL,
|
||||
cpu_count REAL, cpu_usage_percent REAL, memory_total REAL, memory_available REAL,
|
||||
PRIMARY KEY(host_id, sampled_at)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS ec_instance_resource_samples (
|
||||
host_id TEXT NOT NULL, instance_id TEXT NOT NULL, generation INTEGER NOT NULL,
|
||||
phase TEXT NOT NULL CHECK(phase IN ('startup','running')), bucket TEXT NOT NULL,
|
||||
cpu_cores REAL NOT NULL, memory_bytes REAL NOT NULL,
|
||||
PRIMARY KEY(host_id,instance_id,generation,phase,bucket)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS ec_instance_resources_host ON ec_instance_resource_samples(host_id,phase,bucket DESC);
|
||||
CREATE INDEX IF NOT EXISTS ec_instance_resources_fleet ON ec_instance_resource_samples(phase,bucket DESC);
|
||||
CREATE INDEX IF NOT EXISTS ec_instance_resources_retention ON ec_instance_resource_samples(bucket);
|
||||
CREATE TABLE IF NOT EXISTS ec_resource_allowances (
|
||||
scope TEXT NOT NULL, phase TEXT NOT NULL, cpu_cores REAL NOT NULL, memory_bytes REAL NOT NULL,
|
||||
samples INTEGER NOT NULL, window_start TEXT NOT NULL, observed_at TEXT NOT NULL, computed_at TEXT NOT NULL,
|
||||
PRIMARY KEY(scope,phase)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS ec_host_decommissions (
|
||||
host_id TEXT PRIMARY KEY REFERENCES ec_hosts(id),
|
||||
operation_id TEXT NOT NULL UNIQUE REFERENCES ec_host_operations(id),
|
||||
|
||||
Reference in New Issue
Block a user