I have a use case where I want to access the Atlas database through my AWS. For this, I used Data API with API Gateway but this API is giving 3000ms latency, which is too much. My cluster is hosted in AWS Mumbai Region, I also tried VPC Peering but don’t have any idea how to connect from here.
Is there any way to connect Atlas database through API Gateway? My ultimate goal is to read and write data through an API so that I can use this in my application.
Hi Hemendra - what kind of queries are you running? You will be able to get much better latency by setting your data api to be deployed in a single region, since currently your request is probably going from your API gateway → sydney (data api) → mumbai (atlas cluster). Other things to consider are indexing your queries and potentially sizing up your Atlas cluster tier.
to do this you can:
Go to App Services
Click ’ Create new app ’
In the form, choose ‘Advanced’ and choose a local setting
Go to Rules , and create default read and write for your linked cluster
Go to Authentication and enable ’ api key '. Save that config, then create an API key.
Go to HTTPS endpoints and click on the Data API tab. Enable the Data API.
That is very awesome, and things are start working for me now. I create new app in the same region as cluster. But one thing that we have to consider is that we have to make service name the same as cluster name in Linked Data Sources.
to do so you can:
Go to App Services
Select your app
Go to Linked Data Sources , and click on Link a Data Source
Choose a data source and service name. The service name should be the same as the cluster name.