一句话:提出基于机器学习的 GraphQL 查询代价预估方法,在真实商用 API 数据上显著优于静态分析。
GraphQL 查询具有嵌套结构,且底层数据源对客户端不可见,导致盲目执行客户端查询可能带来意想不到的高昂计算与资源开销,对服务提供方造成过载,对客户端造成限流与基础设施压力。因此需要在执行前高效估计查询代价。然而,由于 GraphQL API 设计约定各异、数据源隐藏,基于最坏情况静态查询分析的估计往往严重高估。本文提出一种机器学习方法来高效且准确地估计查询代价,并利用公开商用 API 的查询-响应数据进行验证。实验表明,该框架效率高、预测准确率高,持续大幅优于静态分析方法。
GraphQL is a query language for APIs and a runtime for executing those queries, fetching the requested data from existing microservices, REST APIs, databases, or other sources. Its expressiveness and its flexibility have made it an attractive candidate for API providers in many industries, especially through the web. A major drawback to blindly servicing a client’s query in GraphQL is that the cost of a query can be unexpectedly large, creating computation and resource overload for the provider, and API rate-limit overages and infrastructure overload for the client. To mitigate these drawbacks, it is necessary to efficiently estimate the cost of a query before executing it. Estimating query cost is challenging, because GraphQL queries have a nested structure, GraphQL APIs follow different design conventions, and the underlying data sources are hidden. Estimates based on worst-case static query analysis have had limited success because they tend to grossly overestimate cost. We propose a machine-learning approach to efficiently and accurately estimate the query cost. We also demonstrate the power of this approach by testing it on query-response data from publicly available commercial APIs. Our framework is efficient and predicts query costs with high accuracy, consistently outperforming the static analysis by a large margin.
DOI 原文 ·
@inproceedings{paperbot6477,
title = {Learning GraphQL Query Cost},
author = {Georgios Mavroudeas and Guillaume Baudart and Alan Cha and Martin Hirzel and Jim A. Laredo and Malik Magdon-Ismail and Louis Mandel and Erik Wittern},
booktitle = {ASE},
year = {2021},
doi = {10.1109/ase51524.2021.9678513}
}