Learning GraphQL Query Cost
Authors:
- 1 November 2021
- conference paper
- Published by Institute of Electrical and Electronics Engineers (IEEE)
- p. 1146-1150
Abstract
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.Keywords
This publication has 13 references indexed in Scilit:
- REST vs GraphQL: A Controlled Experiment2020
- An Empirical Study of GraphQL Schemas2019
- Hyperopt-Sklearn2019
- Natural Software Revisited2019
- Migrating to GraphQL: A Practical Assessment2019
- Machine Learning in Compiler OptimizationProceedings of the IEEE, 2018
- End-to-End Deep Learning of Optimization Heuristics2017
- A Machine Learning Approach to SPARQL Query Performance Prediction2014
- On the naturalness of software2012
- Stacked generalizationNeural Networks, 1992