论文标题
GraphQL查询成本分析的原则方法
A Principled Approach to GraphQL Query Cost Analysis
论文作者
论文摘要
Web API的景观正在发展,以满足新客户的需求,并促进提供者如何满足它们。最近的Web API模型是GraphQl,既是查询语言又是运行时。使用GraphQL,客户端查询表达了他们要检索或突变的数据,并且服务器对这些数据或更改进行了准确响应。 GraphQL的表现力对服务提供商来说是有风险的,因为客户可以简洁地要求大量数据,并且对过度复杂的查询做出响应可能是昂贵的或破坏服务的可用性。最近的经验工作表明,许多服务提供商处于危险之中。使用传统的API管理方法是不够的,从业者缺乏估计和衡量其收到的GraphQL查询成本的原则方法。在这项工作中,我们提出了一个线性时间GraphQl查询分析,该分析可以在不执行的情况下测量查询的成本。我们的方法可以应用于单独的API管理层,并与任意的GraphQL后端一起使用。与现有的静态方法相反,我们的分析支持影响查询成本的常见GraphQL惯例,并且根据我们对GraphQL语义的正式规范,我们的分析是正确的。我们使用新的GraphQl查询响应语料库来证明我们的方法的潜力。我们的查询分析始终获得上限范围,相对于真实响应大小,足以适合服务提供商。相比之下,现有的静态GraphQl查询分析表现出过度估计和估计不足,因为它们无法支持GraphQL约定。
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.