MongoDB Realm - Jumpstart 2021, Slow Connection

Hi all,
I am following the tutorial here:
Serverless Functions Explained | MongoDB Realm Backend-as-a-Service | Jumpstart 2021

And have also completed part 4 of the YouTube series with the front end work. I’m using “npm run dev” and I am getting the site to load but the data is loading much slower for me compared to how fast it loads in the video.

I am using a free cluster located in Singapore and I am located in Malaysia if that matters at all for these speeds I am seeing? The homepage will say “0 products” for about 3-5 seconds and then it will load all 16 products. The same goes for the product details page, it will be an entirely white page for about 3-5 seconds and then it will load.

So I’m not sure if serverless functions via MongoDB Realm are also available via CDN in the SEA region?

Hi @Kim_Stewart

What region is your Atlas database in?

Here is a list of regions supported by MongoDB Realm:
Deployment Models & Regions — MongoDB Realm

Depending on the locations, this could be affecting your connection speeds.

From what I can tell, I’m only connected to the free Google Cloud plan in Singapore. Can’t seem to find any other region settings within MongoDB Atlas or Realm to adjust - maybe this is not available for free plans?

Perhaps I should go with creating my own API rather than using Serverless Functions on MongoDB Realm if the connection speeds will be slowed down.

I would set up your free cluster via AWS in Singapore (ap-southeast-1) then create a new realm app and under advanced set the app deployment model to ap-southeast-1. I’m pretty sure the realm infrastructure runs on AWS.

I had similar problems when I first started using realm as my app deployment model was set to global and all my users are in New Zealand. As soon as I moved the app deployment to local then it was much quicker.

I think before something like this was happening.

Realm request → us-west-2 → lookup db in ap-southeast-2 → process data back in us-west-2 → save data to ap-southeast-2 → continue function us-west-2 → deliver data back to NZ

As you can imaging the latency throughout that starts to add up!

1 Like

Also, you won’t be able to change the app deployment model for an existing app so you will need to create a new one. You could just export your current one via the realm-cli and then change the deployment model in the code and then import as a new app :slight_smile:

Thanks for the helpful replies - if I use CloudFlare for Realm serverless functions will it allow for fast connections globally? Or would I need to host the serverless functions on CloudFlare itself?

I will need to check again but for the MongoDB free clusters I believe AWS only offers Hong Kong, while Google Cloud offers Singapore. Good to know that Realm uses AWS… I always just assumed that serverless functions would be spread out globally pick the closest connection to the user via CDN. Maybe this will be coming to MongoDB? Or a paid service that free plan does not offer? (Which is why I am curious if CloudFlare can also resolve this, say for users in United States to avoid long trips around the world)

I was just about to give up on this as I couldn’t get it working for the longest time - but this second time I forgot to include the authentication and collection rules in MongoDB Realm. I tried once more with AWS, sure enough Singapore is there and things are operating much faster now. Thank you very much!

Curious to know about the speeds globally with Serverless functions. Will it load slow on people browsing from another part of the world? (Not in SEA) Or is serverless via Realm hosted globally via CDN?