当前位置: X-MOL 学术arXiv.cs.PL › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
A Principled Approach to GraphQL Query Cost Analysis
arXiv - CS - Programming Languages Pub Date : 2020-09-11 , DOI: arxiv-2009.05632
Alan Cha and Erik Wittern and Guillaume Baudart and James C. Davis and Louis Mandel and Jim A. Laredo

The landscape of web APIs is evolving to meet new client requirements and to facilitate how providers fulfill them. A recent web API model is GraphQL, which is both a query language and a runtime. Using GraphQL, client queries express the data they want to retrieve or mutate, and servers respond with exactly those data or changes. GraphQL's expressiveness is risky for service providers because clients can succinctly request stupendous amounts of data, and responding to overly complex queries can be costly or disrupt service availability. Recent empirical work has shown that many service providers are at risk. Using traditional API management methods is not sufficient, and practitioners lack principled means of estimating and measuring the cost of the GraphQL queries they receive. In this work, we present a linear-time GraphQL query analysis that can measure the cost of a query without executing it. Our approach can be applied in a separate API management layer and used with arbitrary GraphQL backends. In contrast to existing static approaches, our analysis supports common GraphQL conventions that affect query cost, and our analysis is provably correct based on our formal specification of GraphQL semantics. We demonstrate the potential of our approach using a novel GraphQL query-response corpus for two commercial GraphQL APIs. Our query analysis consistently obtains upper cost bounds, tight enough relative to the true response sizes to be actionable for service providers. In contrast, existing static GraphQL query analyses exhibit over-estimates and under-estimates because they fail to support GraphQL conventions.

中文翻译:

GraphQL 查询成本分析的原则方法

Web API 的格局正在不断发展,以满足新的客户需求并促进提供商如何满足这些需求。最近的 Web API 模型是 GraphQL,它既是查询语言又是运行时。使用 GraphQL,客户端查询表达他们想要检索或改变的数据,服务器准确地响应这些数据或更改。GraphQL 的表达能力对服务提供者来说是有风险的,因为客户端可以简洁地请求大量数据,并且响应过于复杂的查询可能代价高昂或破坏服务可用性。最近的实证工作表明,许多服务提供商都处于危险之中。使用传统的 API 管理方法是不够的,从业者缺乏原则性的方法来估算和衡量他们收到的 GraphQL 查询的成本。在这项工作中,我们提出了一个线性时间 GraphQL 查询分析,它可以在不执行查询的情况下测量查询的成本。我们的方法可以应用于单独的 API 管理层,并与任意 GraphQL 后端一起使用。与现有的静态方法相比,我们的分析支持影响查询成本的常见 GraphQL 约定,并且基于我们对 GraphQL 语义的正式规范,我们的分析可以证明是正确的。我们使用两个商业 GraphQL API 的新型 GraphQL 查询-响应语料库展示了我们的方法的潜力。我们的查询分析始终如一地获得成本上限,相对于真实响应大小而言足够严格,以便服务提供商采取行动。相比之下,现有的静态 GraphQL 查询分析表现出高估和低估,因为它们不支持 GraphQL 约定。我们的方法可以应用于单独的 API 管理层,并与任意 GraphQL 后端一起使用。与现有的静态方法相比,我们的分析支持影响查询成本的常见 GraphQL 约定,并且基于我们的 GraphQL 语义的正式规范,我们的分析可以证明是正确的。我们使用两个商业 GraphQL API 的新型 GraphQL 查询-响应语料库展示了我们的方法的潜力。我们的查询分析始终如一地获得成本上限,相对于真实响应大小而言足够严格,以便服务提供商可采取行动。相比之下,现有的静态 GraphQL 查询分析表现出高估和低估,因为它们不支持 GraphQL 约定。我们的方法可以应用于单独的 API 管理层,并与任意 GraphQL 后端一起使用。与现有的静态方法相比,我们的分析支持影响查询成本的常见 GraphQL 约定,并且基于我们的 GraphQL 语义的正式规范,我们的分析可以证明是正确的。我们使用两个商业 GraphQL API 的新型 GraphQL 查询-响应语料库展示了我们的方法的潜力。我们的查询分析始终如一地获得成本上限,相对于真实响应大小而言足够严格,以便服务提供商可采取行动。相比之下,现有的静态 GraphQL 查询分析表现出高估和低估,因为它们不支持 GraphQL 约定。我们的分析支持影响查询成本的常见 GraphQL 约定,并且基于我们对 GraphQL 语义的正式规范,我们的分析可以证明是正确的。我们使用两个商业 GraphQL API 的新型 GraphQL 查询-响应语料库展示了我们的方法的潜力。我们的查询分析始终如一地获得成本上限,相对于真实响应大小而言足够严格,以便服务提供商采取行动。相比之下,现有的静态 GraphQL 查询分析表现出高估和低估,因为它们不支持 GraphQL 约定。我们的分析支持影响查询成本的常见 GraphQL 约定,并且基于我们对 GraphQL 语义的正式规范,我们的分析可以证明是正确的。我们使用两个商业 GraphQL API 的新型 GraphQL 查询-响应语料库展示了我们的方法的潜力。我们的查询分析始终如一地获得成本上限,相对于真实响应大小而言足够严格,以便服务提供商可采取行动。相比之下,现有的静态 GraphQL 查询分析表现出高估和低估,因为它们不支持 GraphQL 约定。我们的查询分析始终如一地获得成本上限,相对于真实响应大小而言足够严格,以便服务提供商可采取行动。相比之下,现有的静态 GraphQL 查询分析表现出高估和低估,因为它们不支持 GraphQL 约定。我们的查询分析始终如一地获得成本上限,相对于真实响应大小而言足够严格,以便服务提供商可采取行动。相比之下,现有的静态 GraphQL 查询分析表现出高估和低估,因为它们不支持 GraphQL 约定。
更新日期:2020-09-15
down
wechat
bug