LocationSpark: In-memory Distributed Spatial Query Processing and Optimization

Mingjie Tang, Yongyang Yu, Ahmed R. Mahmood, Qutaibah M. Malluhi, Mourad Ouzzani, Walid G. Aref

TL;DR

This paper introduces LocationSpark, a new system for processing spatial queries in-memory on distributed clusters. It tackles the challenges of data skew and communication overhead with novel techniques like a query scheduler, a spatial bitmap filter (sFilter), and optimized local execution plans, achieving up to an order of magnitude speedup over existing systems.

What Problem Does This Paper Address?

The increasing prevalence of location-aware applications generates massive amounts of spatial data. Processing this data efficiently for queries like "find all restaurants within 5 miles" or "find the 10 closest points of interest" is a significant challenge. Existing distributed systems often struggle with:

  • Scalability: Handling terabytes of spatial data and a high volume of queries.
  • Query Skew: Certain data partitions becoming overloaded with queries due to uneven data distribution or query patterns, leading to performance bottlenecks.
  • Communication Overhead: Unnecessary data transfer between nodes when queries overlap with partitions that don't contain relevant results.
  • Inefficient In-Memory Processing: Existing systems often don't fully leverage distributed in-memory computation frameworks like Spark, leading to suboptimal performance.

Methods

LocationSpark addresses these challenges with several key innovations:

  • LocationSpark System: Built on Apache Spark, it leverages its distributed in-memory computation and fault tolerance capabilities.
  • Query Scheduler: A novel scheduler that uses a cost model to analyze query skew. It generates optimized query execution plans to balance the load across partitions, mitigating the impact of skewed queries.
  • Spatial Bitmap Filter (sFilter): A lightweight, in-memory spatial index that acts as a pre-filter. Before sending a query to a data partition, the sFilter quickly determines if that partition actually contains relevant data, significantly reducing unnecessary communication and I/O.
  • Optimized Local Execution Plans: Each worker node optimizes its local query execution based on available spatial indexes (like R-trees or Quadtrees) and the nature of the queries it receives.
  • Data Repartitioning: For severely skewed partitions, LocationSpark can dynamically repartition data and queries to achieve better load balancing.

Datasets

The paper evaluates LocationSpark using two real-world datasets:

  • Twitter: Approximately 1.5 Billion tweets (around 250GB) collected over 20 months, restricted to the USA spatial region. This dataset includes tweet identifiers, timestamps, longitude-latitude coordinates, and text.
  • OSMP (OpenStreetMap): Map features from around the world, containing 1.7 Billion points with a total size of 62.3GB.

Two types of queries were generated:

  1. Uniformly Distributed Queries: Sampled uniformly from the datasets.
  2. Skewed Spatial Queries: Synthesized around specific urban areas (e.g., Chicago, San Francisco, New York) to simulate real-world query patterns.

Key Insights and Ideas

  • Query Skew is a Major Bottleneck: The paper highlights that uneven query distribution is a critical performance issue in distributed spatial systems, often more so than data distribution itself.
  • Proactive Filtering is Crucial: The sFilter's ability to quickly prune irrelevant data partitions before costly computations or data transfers is a key enabler of performance gains.
  • In-Memory Optimization Pays Off: By building on Spark and optimizing for in-memory operations, LocationSpark significantly outperforms disk-based or less optimized systems.
  • Adaptability is Key: The sFilter is designed to adapt its structure based on changing data and query patterns, making it robust for dynamic environments.

Key Results

LocationSpark demonstrated significant performance improvements across various scenarios:

  • Spatial Range Search: Up to 50 times faster than Magellan and around 10 times faster than GeoSpark.
  • Spatial Range Join: Achieved an order of magnitude speedup over GeoSpark and SpatialSpark, and significantly outperformed Simba.
  • kNN Search and Join: Outperformed GeoSpark by an order of magnitude and showed substantial speedups over other approaches like PGBJ.
  • sFilter Performance: Achieved one to two orders of magnitude speedup for spatial range search compared to R-tree and Quadtree-based approaches, with minimal memory overhead.
  • Scalability: LocationSpark scales well with an increasing number of workers, showing consistent performance improvements.

Limitations and Future Work

  • NP-Completeness of Optimization: The optimal data repartitioning problem is NP-complete, meaning LocationSpark uses a greedy algorithm that, while effective, doesn't guarantee absolute optimality.
  • sFilter Shrinking Trade-offs: The sFilter's shrink operation, used to manage index size, can increase false positive rates. The paper mentions using caching policies like LRU/MRU for more sophisticated management, but this adds overhead.
  • Future Work: The authors suggest applying their techniques to other distributed systems and exploring more advanced adaptive strategies for the sFilter. They also mention the potential for further optimization of the query scheduler and local execution plans.

Summary updated

BibTeX
@inproceedings{tang2020locationspark,
  author = {Mingjie Tang and Yongyang Yu and Ahmed R. Mahmood and Qutaibah M. Malluhi and Mourad Ouzzani and Walid G. Aref},
  title = {{LocationSpark: In-memory Distributed Spatial Query Processing and Optimization}},
  booktitle = {Frontiers Big Data},
  year = {2020},
  url = {https://openreview.net/forum?id=-76IijEaA0V},
}
Figure