Data locality is a scheduling concept in distributed computing that co-locates computation with its required data to eliminate network transfer latency. By enforcing affinity rules, schedulers like Kubernetes direct pods to nodes where cached datasets or persistent volumes are already present, avoiding costly remote reads.
Glossary
Data Locality

What is Data Locality?
Data locality is a scheduling strategy that minimizes network transfer overhead by placing computational tasks on the same physical node or rack where the required data already resides.
In AI-enhanced RAN architectures, data locality is critical for proactive caching strategies. When a Multi-access Edge Computing (MEC) node predicts content popularity and pre-fetches data, the inference task must execute on that same edge node to achieve sub-millisecond latency, making locality a foundational requirement for edge inference offloading.
Core Characteristics of Data Locality
Data locality is a scheduling strategy that minimizes network I/O by placing computation on the node where the required data resides. It is a critical optimization in distributed systems, from Kubernetes pod scheduling to Apache Spark job execution.
Node Affinity and Anti-Affinity
The primary mechanism for enforcing data locality in container orchestration. Node Affinity attracts pods to specific nodes based on labels, while Pod Anti-Affinity ensures replicas are spread across failure domains.
- RequiredDuringSchedulingIgnoredDuringExecution: A hard rule that must be met for a pod to be scheduled.
- PreferredDuringSchedulingIgnoredDuringExecution: A soft preference that the scheduler tries to satisfy but does not guarantee.
- This is distinct from Taints and Tolerations, which repel pods from nodes unless explicitly tolerated.
Rack and Topology Awareness
Modern schedulers are aware of the physical or virtual topology of the cluster. They use this to optimize data transfer costs.
- Rack Awareness: In Hadoop and Spark, the scheduler knows which nodes share a power supply or network switch to prevent correlated failures.
- Topology Spread Constraints: In Kubernetes, this feature distributes pods across zones, regions, or hosts to maximize availability while respecting data gravity.
- The goal is to keep the network hop count between compute and storage as low as possible, ideally on the same physical host.
Data Gravity
A concept coined by Dave McCrory stating that as data accumulates in a location, services and applications are attracted to it due to the prohibitive cost and latency of moving large datasets.
- Large datasets have a 'gravitational pull' that influences where computation should run.
- This is the inverse of the traditional model where compute was fixed and data was moved to it.
- In practice, this means ETL jobs and analytics engines are deployed in the same availability zone as the data lake or data warehouse.
Cache Affinity and Sticky Sessions
A stateful form of data locality where requests from a specific user or session are routed to the same server that holds their hot data in memory.
- Sticky Sessions: A load balancer configuration that uses cookies or IP hashing to maintain session affinity.
- Consistent Hashing: An algorithm that minimizes cache redistribution when nodes are added or removed, preserving locality.
- This is crucial for in-memory data grids like Redis or Hazelcast, where fetching from a cold cache defeats the purpose of the optimization.
Data Locality in Apache Spark
Spark's scheduler has a sophisticated, multi-tiered data locality preference system that directly impacts job performance.
- PROCESS_LOCAL: Data is in the same JVM. Best case.
- NODE_LOCAL: Data is on the same node (e.g., HDFS). Requires disk I/O.
- RACK_LOCAL: Data is on the same rack. Requires a network hop.
- ANY: Data is elsewhere in the network.
- Spark will wait for a configurable time (
spark.locality.wait) for a local executor to free up before degrading to the next level.
NUMA-Aware Scheduling
Non-Uniform Memory Access (NUMA) is a hardware architecture where memory access time depends on the memory's location relative to a CPU. NUMA-aware scheduling binds processes to specific CPU cores and their local memory banks.
- Prevents the performance penalty of a CPU accessing memory attached to a remote socket.
- Critical for high-performance computing and latency-sensitive database workloads.
- Tools like
numactlon Linux allow manual binding, while modern Kubernetes supports theTopologyManagerpolicy to align pod resources with NUMA nodes.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about data locality in distributed systems, Kubernetes scheduling, and edge computing architectures.
Data locality is a scheduling principle in distributed computing that places computational tasks on or near the node where the required data already resides, minimizing network transfer latency. It works by using affinity rules and topology-aware scheduling to co-locate processing with storage. In practice, a scheduler inspects metadata about data placement—such as HDFS block locations or persistent volume node affinities in Kubernetes—and preferentially assigns workloads to nodes holding the relevant data. This avoids the performance penalty of moving large datasets across congested network links. The concept is foundational to frameworks like Apache Hadoop, which famously moves computation to data rather than data to computation, and is now critical in edge computing, where data generated by IoT sensors must be processed locally to meet sub-millisecond latency budgets.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Data locality is a core principle in distributed computing. These related concepts define how proximity between computation and storage is achieved, measured, and optimized in modern infrastructure.
Temporal Locality
The principle that recently accessed data is likely to be accessed again in the near future. This is the foundational concept behind LRU (Least Recently Used) caching algorithms. In a Kubernetes context, a pod that just processed a user's profile is likely to process it again, making local caching on that node highly efficient. Exploiting temporal locality minimizes redundant network round-trips to remote object stores.
Spatial Locality
The principle that data stored near a recently accessed memory location is likely to be accessed soon. This is critical for sequential I/O patterns and block storage prefetching. In big data frameworks like Apache Spark, spatial locality means processing a block of a Parquet file on the same node where that block physically resides, avoiding expensive shuffle operations across the network fabric.
Affinity & Anti-Affinity
Scheduling rules that dictate where workloads can or cannot run relative to other workloads or data. Node Affinity attracts pods to specific nodes (e.g., those with GPU or SSD labels). Pod Affinity co-locates related services. Pod Anti-Affinity spreads replicas across failure domains. For data locality, these rules ensure a stateful database pod is scheduled on the exact node that holds its persistent volume.
Cache Hit Ratio
A key performance indicator measuring the percentage of data requests served from a local cache versus requiring a remote fetch. A high cache hit ratio directly correlates with lower latency and reduced backhaul load. In edge computing, a hit ratio above 90% is a common target. This metric is the primary measure of data locality effectiveness, calculated as hits / (hits + misses).
Data Gravity
A metaphor describing how large datasets attract applications and services. As data accumulates in a specific location (e.g., a cloud region or an on-premise data lake), the cost and latency of moving it become prohibitive. This gravitational pull forces architects to deploy compute clusters adjacent to the data lake, making data locality a hard requirement rather than an optimization for petabyte-scale analytics.
Sticky Sessions
A load balancer configuration that routes all requests from a specific user session to the same backend server. This creates application-layer data locality by ensuring a user's session state, held in local memory, is always available. While critical for stateful legacy apps, modern cloud-native architectures often prefer externalizing state to a distributed cache like Redis to avoid the scaling limitations of sticky sessions.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us