arXiv:2611.05669cs.DSNov 2026

Manuscript Offprint

arXiv:2611.05669

The Harmonic Online kk-Server Algorithm Is Poly(k)-Competitive

Yichen Huang

Abstract

The online kk-server problem is one of the most fundamental problems in online algorithms. In this problem, kk servers are located in a metric space and serve a sequence of requests at points in the metric space by moving a server there. The HARMONIC algorithm is a very natural algorithm: it chooses a server with probability inversely proportional to its distance from the request. It is also highly efficient, being memoryless and answering each request in O(k)O(k) time. However, its competitive ratio has remained unsettled between the O(2klog⁡k)O(2^k \log k) upper bound (Bartal and Grove, JACM 2000) and the k(k+1)/2k(k+1)/2 lower bound (Raghavan and Snir, 1994, IBM J. Res. Dev.). We prove that HARMONIC is 2k42k^4-competitive on every metric space against adaptive online adversaries. Our analysis uses a potential combining corrected electrical energy with the distances of online servers to their assigned adversary locations.

*Supported in part by NSF grant CNS-2107078. Email: yichenhuang@g.harvard.edu.

1 Introduction

The kk-server problem is one of the central problems in online algorithms [BCL+18; BCR23; CKZ26; KP95; MMS90]. In this problem, kk servers occupy points in a metric space (V,d)(V,d). At each time tt, a request appears at a point rt∈Vr_t \in V, and the algorithm must move a server to rtr_t. The cost is the total distance traveled by the servers. An online algorithm must select a server without knowledge of future requests. The goal is to minimize the competitive ratio, which compares the algorithm's cost with that of an optimal schedule that knows the requests in advance.

The work function algorithm (WFA) was recently shown to achieve competitive ratio kk [CKZ26], which is optimal both for deterministic algorithms and for randomized algorithms against adaptive online adversaries [MMS90; RS94]. Against oblivious adversaries, a recent preprint establishes an O(log⁡2k)O(\log^2 k) upper bound [Ope26a], matching the lower bound in [BCR23].

Although information-theoretically optimal, these competitive ratios come with heavy computational costs. Known implementations of WFA answer each request in time that either depends exponentially on kk or grows with the number of previous requests [CC26], and they require comparable memory to store the work-function values or prior request locations [RS22]. The implementation of the O(log⁡2k)O(\log^2 k)-competitive algorithm also has time and memory usage that grow with the request count [Ope26b]. When time and space are limited, we would like a fast algorithm with small memory usage.

A particularly attractive candidate in this regard is the HARMONIC algorithm, introduced in [RS89; RS94]. On an uncovered request, it selects a server for the request with probability inversely proportional to its distance from the request. This rule is simple and intuitive: nearby servers are more likely to move, while randomization allows every server to be selected. It is also memoryless,1^1 and each decision takes O(k)O(k) distance evaluations and arithmetic operations, independently of the number of points in the metric and the length of the request history.

Unfortunately, the competitive ratio of the HARMONIC algorithm has remained poorly understood. [RS94] proves a lower bound of k(k+1)/2k(k+1)/2, even against an oblivious adversary. [Gro91] establishes that HARMONIC is competitive, and [BG00] gives the best previously known general upper bound, O(2klog⁡k)O(2^k \log k), against adaptive online adversaries. The gap between these bounds leaves open whether HARMONIC's simplicity incurs a polynomial or an exponential loss.

We prove the first polynomial upper bound on HARMONIC's competitive ratio. Thus HARMONIC has a competitive ratio and per-request response time that are both polynomial in kk and independent of the metric size and the request history. To the best of our knowledge, this is the first such joint guarantee.

Theorem 1.1. HARMONIC is 2k42k^4-competitive for the online kk-server problem on every metric space against adaptive online adversaries.

We prove Theorem 1.1 via a novel potential function based on electrical networks. Electrical networks have been used to analyze how HARMONIC repairs a single mismatch while the adversary stays fixed [BCNR02]. However, this analysis does not directly extend to general adaptive interactions: several discrepancies may coexist, and the adversary may move again before they are repaired.

To account for these mismatches together, we assign each online server to an adversary location. The assignment need not be injective: several servers may share an assigned location. An assignment is charged both the total assignment distance and the resulting imbalance relative to

1^1A randomized server algorithm is memoryless if the distribution of its next move depends only on its current server configuration and the current request (cf. Section 2).

one assigned server per adversary location. The potential is the minimum of a weighted sum of these two charges over all assignments.

To measure the imbalance, we build an electrical network on the adversary locations, joining every pair by a resistor whose resistance is their distance. Each location with extra assigned servers supplies one unit of current per extra server, while each location with no assigned server receives one unit. Among flows meeting these supplies and demands, the electrical flow minimizes the energy: the sum of resistance times squared current.

Energy alone, however, need not decrease in expectation when HARMONIC moves. Because it is symmetric, the energy loses information about direction: swapping an extra server and a missing one preserves their energy, although serving distinguishes the source from the requested destination. To capture this distinction, we add a linear correction consisting of a location-dependent charge per assigned server.

We choose this correction so that the decrease in corrected energy from each move between assigned locations is proportional to a voltage difference in one common electrical field. Dividing by the assigned movement distance then gives a quantity proportional to current, matching HARMONIC's reciprocal-distance probabilities. Kirchhoff's law and the triangle inequality control the resulting weighted currents, while the assignment-distance charge accounts for the difference between assigned and actual movements. Together, these bounds show that the expected potential decrease pays for HARMONIC's expected movement. Finally, bounding current magnitudes by the total supply also controls sensitivity to adversary movement, limiting the potential increase to 2k42k^{4} times the distance moved.

Organization. Section 2 sets up the potential framework, and Section 3 reviews the single-mismatch case. Section 4 defines and motivates the potential and establishes its properties. Section 5 combines these properties to prove the competitive ratio. Omitted proof details and examples can be found in the appendices.