Service Affinity in Scheduling and Placement
- Service affinity is a scheduling paradigm where workload-to-resource matching depends on explicit affinity signals, ensuring system stability and minimized delays.
- Methodologies range from queueing-theoretic models to graph-based and declarative frameworks, each optimizing key performance metrics such as throughput, latency, and resource utilization.
- Practical applications include cloud-native systems, microservices, serverless deployments, and edge computing, where tailored scheduling policies improve overall efficiency.
Searching arXiv for recent and foundational papers on service affinity across scheduling, microservices, serverless, and edge placement. Service affinity denotes a class of scheduling and placement problems in which the desirability or feasibility of assigning work to a resource depends on a relation between the workload entity and the execution site. In queueing-theoretic formulations, it is the problem of dynamically assigning typed tasks to servers whose processing capabilities differ by task type so that the system is stable for all admissible loads and delays remain small near saturation (Yekkehkhany et al., 2017). In cloud-native and serverless systems, it is expressed through communication intensity, co-location and anti-affinity rules, privacy or functional tags, and hardware or location requirements that shape microservice, function, or agent placement (Dinh-Tuan et al., 6 Sep 2025, Palma et al., 2024, Zheng et al., 5 Jan 2026). The common structure is a constrained mapping problem: affinity alters the effective service rate, communication cost, feasibility region, or all three simultaneously.
1. Queueing-theoretic foundations
The classical service-affinity problem is a heterogeneous queueing system with servers , task types , arrival processes , and type-server service rates . In the generic model summarized for GB-PANDAS, service times are non-preemptive, arbitrarily distributed with mean , and queue dynamics are
A necessary and sufficient stability condition is the existence of a decomposition , , such that
which defines the capacity region (Yekkehkhany et al., 2017).
This formulation specialized naturally to data locality in large data centers. In MapReduce-style systems, a task is machine-local, rack-local, or remote depending on where its data block resides, with service parameters 0 and corresponding mean service times 1 (Kavousi, 2017). A related large-scale service-system model assigns each job type 2 a primary server subset 3 and a secondary subset 4; primary service occurs at rate 5, secondary service at rate 6 with 7. The dispatcher first seeks an idle primary server, then an idle secondary server, and otherwise sends the job to the lexicographically shortest primary queue, while servers give preemptive priority to primary jobs (Cardinaels et al., 2018).
The analytical objectives have remained stable across these variants. Throughput-optimality requires positive recurrence whenever the arrival-rate vector lies strictly inside the capacity region. Heavy-traffic optimality studies sequences 8 on the boundary and asks whether the policy minimizes 9 to first order under diffusion scaling (Yekkehkhany et al., 2017). This framing explains why affinity is not merely a locality heuristic: it is a structural modification of the service process, and hence of both stability and delay.
2. Formal representations of affinity
Across the literature, service affinity is represented in several mathematically distinct but structurally related ways.
| Setting | Affinity representation | Optimization target |
|---|---|---|
| Queueing and data locality | 0, 1, primary/secondary sets | stability and delay |
| Microservice placement | 2, 3, cut weights | minimum cross-domain cut |
| Serverless and cluster provisioning | 4, 5, 6, 7 | latency, feasibility, node minimization |
| Edge agent placement | 8 | feasible low-hop embedding |
In graph-based microservice systems, affinity is an edge weight. SAGA defines five primitive metrics over a sliding window 9: data affinity 0, coupling affinity 1, privacy affinity 2, functional affinity 3, and operational affinity 4. Raw service affinity is a weighted sum
5
followed by min-max normalization to obtain edge weights 6 in a Service Affinity Graph 7 (Dinh-Tuan et al., 6 Sep 2025). DREAMS adopts the service-affinity notion introduced in SAGA but uses a streaming-window form in which, for microservices 8 and 9, 0 combines communication rate, dependency, and tunable weights 1 that can incorporate data privacy, resource sharing, or domain-specific factors (Dinh-Tuan et al., 9 Sep 2025).
In serverless systems, affinity is often a hard logical predicate. The aAPP model associates each function tag 2 with an affine set 3 that must already appear on the same worker and an anti-affine set 4 that must not appear there. A worker 5 is affinity-valid for function 6 with tag 7 exactly when
8
(Palma et al., 2024). In shared-cluster provisioning for long-running applications, affinity is a directed restriction graph 9 with parameters 0, where 1 is the maximum number of replicas of 2 that may co-locate on a node if at least one replica of 3 is there (Mommessin et al., 2022).
These formulations differ in algebraic form—service-rate matrices, graph weights, Boolean co-location predicates, hardware-label constraints—but all encode non-exchangeability. A resource is not simply “faster” or “slower” in the abstract; it is better or worse for a particular workload entity.
3. Affinity scheduling in data centers and service systems
The affinity-scheduling literature developed a sequence of algorithms that trade off practicality, information requirements, and optimality guarantees. Early approaches with theoretical guarantees included fluid model planning, the MaxWeight algorithm, and the generalized 4-rule, but these were described as impractical for data center applications because of non-realistic assumptions (Yekkehkhany et al., 2017). In MapReduce data-locality systems, the same tension appears between heuristic methods such as Delay Scheduling and Quincy, and algorithms with explicit throughput or heavy-traffic guarantees (Kavousi, 2017).
GB-PANDAS addresses the multi-level locality case with 5 locality levels and service-rate parameters 6. Each server 7 keeps sub-queues 8, and its expected workload is
9
Upon arrival of a task of type 0, routing uses the weighted-workload rule
1
and scheduling is strict priority from 2 to 3 (Yekkehkhany et al., 2017). Throughput optimality is proved by augmenting the state to 4, choosing the Lyapunov function 5, and establishing a negative 6-step drift: 7 The proof uses a workload evolution equation, a routing lemma, a service lemma over 8 slots, and an age lemma (Yekkehkhany et al., 2017).
The algorithmic significance lies in the assumptions it avoids. GB-PANDAS is proved throughput-optimal for arbitrary service-time distributions, whereas much previous theoretical work assumed geometric service times. In simulations on a 5,000-server cluster with 4 locality-levels, log-normal service times with 9, 0, 1, and 2, and comparisons against FCFS, JSQ-Priority, and JSQ-MaxWeight, GB-PANDAS halved the mean completion time relative to JSQ-MaxWeight under high load, with up to 3 improvement at 4 (Yekkehkhany et al., 2017).
Blind GB-PANDAS removes knowledge of both arrival rates and service rates. It maintains estimates 5, updates them from service completions, and alternates exploitation with exploration using a monotone-decreasing 6 satisfying 7. In exploitation, an arriving type-8 task is routed by
9
while scheduling serves the highest-priority nonempty sub-queue; exploration randomly samples servers or sub-queues so that all locality classes are observed infinitely often (Yekkehkhany et al., 2019). The resulting Markov chain 0 is irreducible, aperiodic, and positive-recurrent whenever 1. Experiments with three servers, three task types, Poisson arrivals, and log-normal heavy-tailed service times found that Blind GB-PANDAS remained stable up to capacity and delivered substantially lower delays in heavy traffic, often 2 better than Max-Weight or 3-rule with exploration (Yekkehkhany et al., 2019).
Related models clarified structural phenomena that are not visible in single-rate load balancing. In the primary-secondary model, affinity coupling bounds the original non-exchangeable system by reference systems such as RA, MJSQ4, and JSQ5, yielding explicit stability conditions and performance bounds (Cardinaels et al., 2018). In the symmetric combinatorial model, the fluid limit exhibits two regimes: a unique all-busy fixed point for small 6, and bistability when 7, with one stable no-queueing mode, one unstable fixed point, and metastability on long time scales (Cardinaels et al., 2018). A different extension studies job-server affinity under uncertainty of job types and threshold-based rerouting or replication. There, full replication 8 maximizes the achievable stability bound in highly unbalanced speed regimes, zero redundancy 9 is best in nearly balanced regimes, and a suitable threshold can reduce expected latency under 0 approximations (Raaijmakers et al., 2020).
4. Graph-based service affinity in microservice systems
In microservice architectures, service affinity is often operationalized as a weighted interaction graph and solved as a partitioning problem. SAGA models the system as an undirected weighted graph 1, where 2 is the set of microservice instances, 3, and 4 is the normalized affinity weight (Dinh-Tuan et al., 6 Sep 2025). Placement is then formulated as a minimum-weight 5-cut: partition 6 into 7 disjoint subsets 8 so as to minimize the total weight of edges crossing partitions. An integer-programming form minimizes 9 subject to assignment, cut-consistency, and optional balance constraints (Dinh-Tuan et al., 6 Sep 2025).
SAGA uses a modified 00-way Kernighan-Lin heuristic. Each two-way pass runs in 01 on a subset of size 02; recursively splitting until 03 subsets are obtained yields total worst-case time 04 (Dinh-Tuan et al., 6 Sep 2025). The framework is organized as three services within Kubernetes: Cluster Monitoring Service, Affinity-based Clustering Service, and Migration Orchestration Service. In a prototype built on Microsoft eShopOnWeb with RabbitMQ and deployed on Google Kubernetes Engine with 1 control-plane and 3 worker nodes, SAGA reduced mean latency from 05 ms to 06 ms over 200 requests, a 07 reduction, while also tightening the latency distribution (Dinh-Tuan et al., 6 Sep 2025).
DREAMS extends the graph view to a decentralized compute-continuum setting. For each candidate migration of microservice 08 into cluster 09, it computes a Cluster Affinity Score
10
defines intra-domain and best inter-domain affinities,
11
and uses the Affinity Gain
12
as the basic migration signal (Dinh-Tuan et al., 9 Sep 2025). The global problem is to partition the interaction graph 13 with edge weights 14 so as to minimize the total affinity cut across domain boundaries, subject to capacity constraints such as CPU and memory limits (Dinh-Tuan et al., 9 Sep 2025).
The distinctive feature of DREAMS is decentralized coordination. Each Local Domain Manager proposes at most one migration per leader term using a net score 15, where 16, and proposes only if 17. Followers perform cost-benefit voting using a normalized local-impact score, a latency-change term 18, an affinity-penalty weight 19, and a scaled penalty 20, voting YES when 21 (Dinh-Tuan et al., 9 Sep 2025). This exchange is embedded into a Raft cycle that tolerates 22 crashes and commits after a quorum of 23 acknowledgements. In deployments of 3–20 LDMs across Google-Cloud regions, mean registration time grew sub-linearly from approximately 24 ms to approximately 25 ms, worst-case convergence from 26 ms to 27 ms, and migration voting latency from 28 ms to 29 ms. On a 10-service graph with initial inter-domain cut weight 30, DREAMS converged to the offline-computed optimum of 31 (Dinh-Tuan et al., 9 Sep 2025).
5. Serverless functions and shared-cluster provisioning
In serverless systems, affinity can be imposed declaratively as a scheduling constraint rather than inferred from traffic. The aAPP extension to APP lets each tag specify blocks containing worker sets, strategies, invalidate constraints, and an affinity list mixing positive and negated tags. Scheduling evaluates blocks in order, filters candidate workers by capacity, concurrency, and the affinity predicate, then chooses a worker by best_first or any; if no block succeeds, it either fails or follows the default tag, depending on followup (Palma et al., 2024). The complexity per request is linear in policy size and candidate workers, stated as 32 (Palma et al., 2024).
A prototype integrated into Apache OpenWhisk modified the Controller’s load-balancer, added a parser for .aapp scripts, and maintained state tables for active functions and tag activations (Palma et al., 2024). In an affinity-aware “divide-et-impera” scenario with two interdependent functions and co-tenant heavy functions across two geo-zones, full aAPP affinity plus anti-affinity achieved mean latency 33 ms, median 34 ms, and 95% tail 35 ms after 250 runs. The anti-affinity-only baseline had mean 36 ms, median 37 ms, and tail 38 ms, while plain APP had mean 39 ms, median 40 ms, and tail 41 ms; retries to read from the database were 42 under aAPP versus 43–44 in the baselines (Palma et al., 2024). In non-affinity microbenchmarks, differences between APP and aAPP were under 45 ms on average, and both were under 46 ms relative to vanilla OpenWhisk (Palma et al., 2024).
Static analysis becomes much harder once positive affinity is admitted. The formal study of aAPP reachability shows that without affinity, reachability and co-occurrence are decidable in linear time, while full affinity and anti-affinity make reachability PSPACE-complete. A polarized fragment with only anti-affinity remains linear, whereas positive-affinity-only reachability is NP-hard and still in PSPACE (Palma et al., 2024). This result identifies a precise trade-off between policy expressivity and analyzability.
ICPS addresses serverless workflow execution from a dynamic-scaling perspective. It predicts workflow and function concurrency with an LSTM, maps workflow-level predictions to function-level predictions by
47
sets pre-warm targets 48, and deploys new instances using an Affinity Deployment Strategy based on invocation-frequency scores
49
Placement minimizes the penalty from cross-node invocations 50 subject to worker memory limits (Chen et al., 9 Apr 2025). Against six baselines, ICPS reported up to 51 reduction in average workflow response time under high concurrency 52 requests), 53 fewer cold starts, and an overall 54 improvement in 55; when inter-node latency 56 was 57–58 ms, affinity-based co-location yielded a 59 reduction in end-to-end critical-path latency (Chen et al., 9 Apr 2025).
Affinity also appears as a provisioning constraint in shared clusters running long-running applications. The ILP model for affinity-aware resource provisioning uses binary placement variables 60, node-use variables 61, and application-presence variables 62, with node-count objective 63, capacity constraints, and general co-location upper bounds
64
Special cases encode must-together co-location and anti-affinity exactly (Mommessin et al., 2022). The paper studies Application-Centric, Node-Centric, and Multi-Node heuristics, reporting, for example, 65 deviation with Multi-Node Spread+WFD (BS) on static 2-dimensional instances with 66, and 67 deviation on static large-scale instances with 68 (Mommessin et al., 2022). The best heuristics reduced node usage by up to approximately 69 relative to naïve AC approaches or existing schedulers, corresponding to approximately 70 servers in a 5,000-node scenario, approximately 71 GWh/year, and approximately 72 kton 73 avoided under the stated power assumptions (Mommessin et al., 2022).
6. Hard constraints, semantic affinity, and open issues
Recent work extends service affinity beyond communication locality to explicit hardware and semantic constraints. In AgentVNE, service affinity refers to hard, often hardware- or location-based dependencies such as a Trusted Execution Environment or a camera interface. Each virtual node 74 carries required hardware attributes
75
and feasibility is enforced by
76
To bias placement toward affinity-constrained nodes, AgentVNE augments a substrate node’s resource tuple 77 with a virtual resource-bias vector 78, then applies a dual-stream GCN-plus-Transformer encoder, a column-wise neural tensor network, supervised pre-training, and PPO fine-tuning (Zheng et al., 5 Jan 2026). In the reported simulations, AgentVNE reduced workflow communication latency to less than 79 of baselines and improved service acceptance rate by approximately 80 under high-load scenarios (Zheng et al., 5 Jan 2026).
The progression from queueing models to graph partitioning, declarative policies, and semantic inference has not removed the core tensions of service affinity. One recurring issue is information and coordination overhead. GB-PANDAS requires per-server per-level queue lengths and central knowledge of 81, which may incur messaging cost; proposed extensions include power-of-82 sampling of workloads, join-idle-queue hybrids, and decentralized approximations (Yekkehkhany et al., 2017). DREAMS addresses coordination by decentralizing placement decisions with Raft-based consensus, but still measures voting and registration latencies explicitly (Dinh-Tuan et al., 9 Sep 2025). Another issue is unresolved optimality: for GB-PANDAS, a full heavy-traffic proof remains open, although simulations and an informal state-space-collapse argument suggest concentration on a single dimension in the Halfin-Whitt regime and superiority over JSQ-MaxWeight except in degenerate two-level cases (Yekkehkhany et al., 2017).
A further tension is that affinity can improve locality while worsening interference or verification complexity. ICPS notes that co-locating high-affinity functions can increase CPU and memory contention, and suggests extending affinity with an interference model 83 (Chen et al., 9 Apr 2025). The formal analysis of aAPP shows that adding general affinity elevates reachability checking from linear time to PSPACE-complete, even though anti-affinity alone remains tractable (Palma et al., 2024). These results suggest that service affinity is not a single technique but a design axis: one chooses how much of the system’s heterogeneity, interaction structure, or governance policy to encode explicitly in placement, and then accepts the corresponding cost in state, computation, or analysis.
Within that design axis, the field has converged on a broad principle. Whether the affinity signal is a service-rate matrix, a locality level, a graph edge weight, a co-location predicate, or a hardware-label set, performance improves when the scheduler or orchestrator uses the signal directly rather than treating resources as exchangeable. The exact gain depends on the model class: throughput and heavy-traffic behavior in typed-task queues (Yekkehkhany et al., 2017), cut-weight and latency in microservice graphs (Dinh-Tuan et al., 6 Sep 2025, Dinh-Tuan et al., 9 Sep 2025), cold-start and workflow response in serverless systems (Chen et al., 9 Apr 2025, Palma et al., 2024), node count and carbon impact in shared clusters (Mommessin et al., 2022), and feasible low-hop embedding in edge agentic AI (Zheng et al., 5 Jan 2026).