I'm trying to understand if GraphQL is a good architectural decision for large-scale apps.
One thing that caught my eye is the fact that it uses a single endpoint for all requests.
From http://graphql.org
Access the full capabilities of your data from a single endpoint.
Is this a bottleneck? Where all requests go through a single API Gateway (a single endpoint)?
Asking for a friend. Thanks.
EDIT: Pointing me to any documentation that addresses this would be helpful.
The short answer is no.
It's probably best to examine where a bottleneck might be and prove to ourselves that it isn't actually a bottleneck.
First, when you make a request, you do a DNS lookup for your domain, e.g. www.myapi.com. That will return 1 or more IP addresses. Basically, you choose one and send your request to that address. So far, this has nothing to do with the actual endpoint, e.g. /graphql
, but it is the first step.
You mentioned API Gateway which leads me to believe you are talking about deploying a GraphQL API on AWS.
Second, your request arrives at your load balancer. If you are using API Gateway, that is your load balancer. If you are on AWS and not using API Gateway, you might be using an ELB. In either case, the job of a load balancer is to look at the endpoint, see which servers are responsible for handling that endpoint and forwarding the request to one of them. Whether there is a single endpoint or 100 endpoints, this job is exactly the same. The fact that there is only one endpoint in the case of GraphQL actually makes this job easier.
It's worth mentioning that the load balancer is not just a single machine. There are many machines that make up a single API Gateway or ELB and they are all doing the same job. This is not only for scalability but also for high availability.
Next, the request is received by the server that the load balancer picked and it is handled. Again, there are many identical servers doing the same job for other requests. In the case that you are using AWS Lambda to handle your requests, your servers are essentially running in containers which AWS will scale up and down horizontally for you.
At this point, the endpoint is no longer relevant and therefore no longer is a contributing factor to any bottlenecks.
I hope that is convincing enough that not only is a single endpoint not a bottleneck but it makes the job of a load balancer the tiniest amount easier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With