Large-Scale Intelligent Microservices

Mark Hamilton, Nick Gonsalves, Christina Lee, Anand Raman, Brendan Walsh, Siddhartha Prasad, Dalitso Banda, Lucy Zhang, Lei Zhang, William T. Freeman

Abstract

This paper introduces a framework that bridges the gap between massive-scale databases and managed AI services by integrating the HTTP protocol directly into Apache Spark. By combining cluster-wide distribution with a novel asynchronous parallelism layer, the authors enable developers to orchestrate "intelligent microservices" (such as vision and speech APIs) across hundreds of machines, achieving orders-of-magnitude higher throughput than standard methods.

Introduction

Modern Machine Learning (ML) is a resource-intensive endeavor, often requiring specialized hardware like GPUs or TPUs. To manage costs and complexity, many organizations adopt a service-based architecture where ML models are hosted behind web APIs. However, integrating these APIs with Big Data systems like Spark or SQL databases is notoriously difficult. Standard database syntax is restrictive, and typical web clients are synchronous, meaning a computer sits idle waiting for a web response before processing the next row of data. When dealing with billions of rows, this idle time makes large-scale AI enrichment prohibitively slow and expensive.

System Architecture

The authors propose a system called "Cognitive Services for Big Data," built on three key pillars designed to bring ML directly to the data rather than moving data to an ML platform.

System architecture of Cognitive Services for Big Data on Spark, illustrating the flow from source datastores to sink datastores via a Spark cluster.
  1. HTTP on Spark: The HTTP protocol is integrated into the Spark SQL type system. This allows web requests and responses to be treated like any other data column, enabling Spark’s Catalyst Optimizer to efficiently manage web-service-based queries.
  2. Containerized Microservices: To mitigate the "network tax" (latency from cloud communication), the authors created a version where AI services run in Docker containers directly on Spark worker nodes. This co-location allows for local process communication, which is significantly faster than traditional cloud calls.
  3. Fluent API: The system uses a "Fluent API" that allows users to chain complex AI tasks—such as detecting faces, transcribing audio, and writing to SQL—in just a few lines of code.

Asynchronous Parallelism and Scalability

The "secret sauce" of the framework is the transition from synchronous to asynchronous parallelism. Standard Spark operations typically block a thread while waiting for a network response. The authors introduced a non-blocking mapPartitions variant that allows a single Spark thread to manage multiple concurrent web requests.

Comparison of Asynchronous, Multi-Threaded, and Multi-Machine Parallelism strategies used to maximize throughput.

This approach maximizes CPU and network utilization without requiring extra hardware. By allowing threads to multi-task while waiting for network I/O, the system achieves a performance jump of over an order of magnitude.

Experimental Evaluation

The researchers evaluated the system using diverse datasets, including 10,000 sentences from Project Gutenberg, 1,000 images from The Metropolitan Museum of Art, and various public datasets for sentiment analysis (SemEval 2013), face detection (FDDB), and anomaly detection (Yahoo/Twitter).

Key Results

  • Massive Speedups: In throughput tests for Sentiment Analysis, the asynchronous method processed 200 rows/sec/node, compared to just 3.0 rows/sec/node using standard Python libraries.
  • Linear Scalability: The system demonstrated near-perfect scaling; doubling the number of Spark partitions resulted in a near-perfect doubling of throughput, provided the back-end service could handle the load.
  • Latency Reduction: Using local containers reduced latency for OCR tasks from approximately 1540ms (cloud) to 374ms (local).
  • Quality Parity: Containerized versions of AI services performed identically in quality to cloud-hosted counterparts, proving that on-premise AI does not have to sacrifice accuracy for speed.

Conclusion

While the current work focuses on HTTP, future directions include exploring more optimized protocols like gRPC and further integrating these tools into the broader SparkML ecosystem. The system effectively addresses the bottlenecks of service-based ML, though ultimate speed remains capped by the back-end service provider's capacity and rate limits.

Summary updated

BibTeX
@inproceedings{hamilton2020large,
  author = {Mark Hamilton and Nick Gonsalves and Christina Lee and Anand Raman and Brendan Walsh and Siddhartha Prasad and Dalitso Banda and Lucy Zhang and Lei Zhang and William T. Freeman},
  title = {{Large-Scale Intelligent Microservices}},
  booktitle = {IEEE BigData},
  year = {2020},
  doi = {10.1109/bigdata50022.2020.9378270},
}
Figure