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.
翻译:图形QL 是一种对API 的查询语言,也是执行这些查询的准备时间,从现有的微服务、REST API、数据库或其他来源获取所要求的数据。 它的清晰度和灵活性使得它成为许多行业,尤其是通过网络对API提供者的吸引对象。 盲目服务在图形QL 中的客户查询的一大缺点是,查询的成本可能出乎意料地过高,为提供者造成计算和资源超载,以及API 超标和基础设施超载。为了减轻这些缺陷,在进行查询之前必须有效地估计查询费用。估计查询费用具有挑战性,因为“GreagQL”查询有一个嵌套结构,“GreagQL API”查询遵循不同的设计惯例,而基本的数据来源是隐蔽的。基于最坏情况的静态查询分析的估算结果,由于它们往往严重地高估测成本,因此其成功程度有限。我们建议采用机器学习方法,以高效率和准确估计查询费用。我们通过从公开的精确度预测、持续可靠的商业访问框架测试查询数据来显示这一方法的威力。