The k-Server Problem and Its Conjecture
Paging asks which page to evict; all evictions cost the same. Give the pages locations in space, make the cost of serving a request depend on how far something must move, and paging becomes the -server problem of Manasse, McGeoch and Sleator (1988; journal version 1990). It is the most studied problem in competitive analysis, partly because its central question has resisted every attack: is there a deterministic -competitive algorithm on every metric space? This lesson defines the problem, proves the lower bound on every metric, shows that the obvious greedy rule fails, and states carefully what is known about the conjecture.
The problem
There is a metric space and servers located at points of . Each request is a point ; to serve it, some server must move to (if a server is already there, the request costs nothing). The cost is the total distance moved by all servers. An online algorithm decides which server to send, without knowing future requests.
- Paging is the -server problem on the uniform metric, all distances 1: points are pages, a server at a point means the page is cached, and moving a server is evicting one page and loading another.
- Weighted paging (pages with different load costs) is the -server problem on a star, a weighted tree with the pages as leaves.
- Motivation from the original paper: disk heads or repair vehicles that must travel to requests, which is where the name comes from.
A lazy algorithm moves only one server per request, the one that serves it. Any algorithm can be made lazy without increasing its cost (by the triangle inequality, a server's detours can be postponed until it is needed), so OPT can be assumed lazy. OPT itself is computable in polynomial time by a minimum-cost flow (Chrobak, Karloff, Payne and Vishwanathan, 1991); for small instances dynamic programming over configurations is enough.
Greedy is not competitive
The natural rule, send the closest server, fails badly. On a line, put servers at 0 and 100 and request 1, 0, 1, 0, ... Greedy shuttles the server near 0 back and forth, paying 1 per request forever, while OPT moves the far server to 1 once (cost 99) and then pays nothing.
from itertools import combinations
def opt_cost(start, reqs):
"""Offline optimum by dynamic programming over lazy configurations (sorted tuples)."""
dp = {tuple(sorted(start)): 0}
for r in reqs:
nxt = {}
for conf, c in dp.items():
if r in conf:
options = [(conf, 0)]
else:
options = [(tuple(sorted(conf[:i] + (r,) + conf[i + 1:])), abs(conf[i] - r)) for i in range(len(conf))]
for new, extra in options:
if c + extra < nxt.get(new, float("inf")):
nxt[new] = c + extra
dp = nxt
return min(dp.values())
def greedy_cost(start, reqs):
servers, cost = list(start), 0
for r in reqs:
i = min(range(len(servers)), key=lambda j: (abs(servers[j] - r), j))
cost += abs(servers[i] - r)
servers[i] = r
return cost
start = (0, 100)
for n in [10, 100, 1000]:
reqs = [1, 0] * (n // 2)
print(f"{n:5} requests: greedy {greedy_cost(start, reqs):5}, OPT {opt_cost(start, reqs):3}") 10 requests: greedy 10, OPT 10
100 requests: greedy 100, OPT 99
1000 requests: greedy 1000, OPT 99
The greedy cost grows linearly while OPT stays at 99, so greedy is not -competitive for any . Greedy ignores the future entirely; a competitive algorithm must sometimes move a far server even though a near one could serve the request more cheaply now. Double Coverage does exactly that, in a controlled way.
The lower bound , on every metric
Theorem (Manasse, McGeoch and Sleator, 1990). On every metric space with at least points, no deterministic online -server algorithm has competitive ratio less than .
Proof (the averaging argument)
Fix points and a deterministic algorithm ALG whose servers occupy of them. The adversary always requests the one point not covered by ALG. Then ALG moves some server from a point to the request , and the next request is , the point ALG just left. So ALG pays exactly at step (if ALG moves more than one server it pays even more), and
Now define offline algorithms . Each occupies of the points, and they are chosen so that their uncovered points are different points, all different from . Each serves a request as follows: if covers , do nothing; otherwise move the server at to .
Invariant: just before request , all the cover and their uncovered points are exactly the points other than . Since , exactly one misses ; it moves its server from to , so its uncovered point becomes , and the invariant holds again with in place of .
So at each step exactly one of the algorithms pays and the others pay nothing. Summing, , plus a bounded start-up term for moving the into their initial configurations. The cheapest pays at most the average, so
and the sums grow without bound as the sequence gets longer.
The program runs this adversary on random metrics of points against two deterministic algorithms (greedy, and "move the server that has moved least so far") and checks both the inequality and the averaging identity with an exact OPT.
import random
from itertools import permutations
def opt_general(d, start, reqs):
dp = {frozenset(start): 0}
for r in reqs:
nxt = {}
for conf, c in dp.items():
options = [(conf, 0)] if r in conf else [(conf - {x} | {r}, d[x][r]) for x in conf]
for new, extra in options:
nxt[new] = min(nxt.get(new, float("inf")), c + extra)
dp = nxt
return min(dp.values())
def adversary(d, k, rule, steps):
servers, moved, cost, reqs = list(range(k)), [0] * k, 0, []
for _ in range(steps):
r = next(p for p in range(k + 1) if p not in servers)
reqs.append(r)
i = rule(d, servers, moved, r)
cost += d[servers[i]][r]
moved[i] += d[servers[i]][r]
servers[i] = r
return cost, reqs
greedy = lambda d, s, moved, r: min(range(len(s)), key=lambda j: (d[s[j]][r], j))
least_moved = lambda d, s, moved, r: min(range(len(s)), key=lambda j: (moved[j], j))
rng = random.Random(9)
for k in [2, 3, 4]:
pts = [(rng.random(), rng.random()) for _ in range(k + 1)]
d = [[round(((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) ** 0.5, 4) for b in pts] for a in pts]
for name, rule in [("greedy", greedy), ("least-moved", least_moved)]:
alg, reqs = adversary(d, k, rule, 600)
tour = sum(d[a][b] for a, b in zip(reqs, reqs[1:]))
opt = opt_general(d, range(k), reqs)
print(f"k = {k}, {name:11}: ALG {alg:8.3f}, sum d(r_t, r_t+1) {tour:8.3f}, OPT {opt:7.3f}, ALG/OPT {alg / opt:.3f}")k = 2, greedy : ALG 232.200, sum d(r_t, r_t+1) 231.813, OPT 0.475, ALG/OPT 489.254
k = 2, least-moved: ALG 290.400, sum d(r_t, r_t+1) 290.013, OPT 145.200, ALG/OPT 2.000
k = 3, greedy : ALG 133.320, sum d(r_t, r_t+1) 133.098, OPT 0.419, ALG/OPT 318.034
k = 3, least-moved: ALG 342.799, sum d(r_t, r_t+1) 342.380, OPT 66.882, ALG/OPT 5.125
k = 4, greedy : ALG 103.057, sum d(r_t, r_t+1) 102.885, OPT 0.417, ALG/OPT 246.902
k = 4, least-moved: ALG 323.005, sum d(r_t, r_t+1) 322.373, OPT 30.498, ALG/OPT 10.591
Both algorithms pay at least times OPT (up to the start-up term), whatever their rule: the adversary's sequence is built from the algorithm's own moves, and ALG's cost equals the length of the request tour up to its first step. Greedy is far worse than here; the theorem only says that no algorithm escapes below .
In C++
Offline OPT by dynamic programming for on a line, the tool used to evaluate online algorithms in experiments. A lazy configuration is a pair of server positions; every request moves one of the two servers. For requests the table has one entry per possible position of the other server (a previous request or a start position), so the program runs in time.
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <random>
#include <vector>
int main() {
std::mt19937 rng(10);
std::vector<long long> reqs;
for (int t = 0; t < 2000; ++t) {
bool left = rng() % 2;
reqs.push_back(left ? rng() % 20 : 980 + rng() % 20); // two clusters far apart
}
// dp: position of the server NOT at the last request -> min cost; last request = where the other server is
std::map<long long, long long> dp = {{1000, 0}}; // servers start at 0 and 1000, "last" = 0
long long last = 0;
for (long long r : reqs) {
std::map<long long, long long> nxt;
for (auto [other, c] : dp) {
auto relax = [&](long long o, long long v) {
auto it = nxt.find(o);
if (it == nxt.end() || v < it->second) nxt[o] = v;
};
relax(other, c + std::llabs(last - r)); // the server at `last` moves to r
relax(last, c + std::llabs(other - r)); // the other server moves to r
}
dp.swap(nxt);
last = r;
}
long long opt = dp.begin()->second;
for (auto [o, c] : dp) opt = std::min(opt, c);
long long greedy = 0, a = 0, b = 1000;
for (long long r : reqs) {
if (std::llabs(a - r) <= std::llabs(b - r)) { greedy += std::llabs(a - r); a = r; }
else { greedy += std::llabs(b - r); b = r; }
}
std::printf("2 servers, two clusters: OPT %lld, greedy %lld, ratio %.3f\n", opt, greedy, double(greedy) / opt);
}2 servers, two clusters: OPT 13156, greedy 13156, ratio 1.000
With one cluster per server greedy happens to be optimal; the failure above needed requests between a near server and a far one.
The -server conjecture
Conjecture (Manasse, McGeoch and Sleator, 1988). On every metric space, there is a deterministic -competitive -server algorithm.
By the lower bound this would be best possible. What is known, stated with its conditions:
| Setting | Best deterministic ratio known | Reference |
|---|---|---|
| uniform metric (paging) | , tight | Sleator and Tarjan, 1985 |
| , every metric | , tight | Manasse, McGeoch and Sleator, 1990 |
| metrics with exactly points | , tight | Manasse, McGeoch and Sleator, 1990 |
| the line, and trees | , tight (double coverage) | Chrobak, Karloff, Payne and Vishwanathan, 1991; Chrobak and Larmore, 1991 |
| every metric, first finite bound | a function of only (exponential) | Fiat, Rabani and Ravid, 1990 |
| every metric | (work-function algorithm) | Koutsoupias and Papadimitriou, 1995 |
For general metrics the gap between and is open. The work-function algorithm is conjectured to be -competitive itself, and it is known to be -competitive in several special cases (The Work-Function Algorithm). The randomized version of the conjecture, that is achievable against an oblivious adversary on every metric, was refuted in 2023 (Randomized k-Server).
Test yourself
Which special case of the -server problem is paging?
- The line
- The uniform metric, all distances 1
- A tree with leaves
- The Euclidean plane
In the lower-bound proof, how many of the offline algorithms pay at each request?
- None
- Exactly one, and it pays
- All
- Half of them
Why is the greedy rule (move the closest server) not competitive?
- It moves too many servers
- Requests alternating between two nearby points next to one server make it pay every time, while OPT moves a far server once
- It is randomized
- It is -competitive
What is the status of the deterministic -server conjecture on general metrics?
- Proved: on every metric
- Open: the best known general bound is , and is a lower bound
- Refuted in 2023
- Only known for