Comparing Login Speeds: MongoDB Realm's Slow Performance Explained

I recently created a web application utilizing MongoDB databases hosted on Atlas, connected through Stitch. However, I discovered that Stitch has been deprecated and replaced by MongoDB Realm. So, I decided to update my site to use Realm instead of Stitch. Interestingly, after the update, I noticed that anonymous log-ins were significantly slower for some reason. To investigate this, I conducted some quick tests following the code provided in MongoDB's documentation:

let t0 = performance.now()
app.logIn(Realm.Credentials.anonymous()).then(() => {
         let t1 = performance.now()
         db.collection('test').find({
                category: "test"
            }, {limit: 10})
        console.log("Login took " + (t1 - t0) + " milliseconds.")
    })

It now takes an astonishing 1200 ms to log in.

let t0 = performance.now()
app.auth.loginWithCredential(new stitch.AnonymousCredential()).then(() => {
            let t1 = performance.now()
            db.collection('test').find({
                category: 'test'
            }, {limit: 10}).asArray()
            console.log("Login took " + (t1 - t0) + " milliseconds.")
        })

In comparison, with Stitch, it usually only takes under 20 ms to log in.

Any insights into why there is such a difference or suggestions on how to resolve this issue? I am aware of the option to first authenticate a user as outlined in their documentation, but even trying that method resulted in slow log-ins.

Is it necessary to transition to the new Realm App, considering that the old Stitch implementation may stop functioning in the near future? Any information on this matter would be greatly appreciated ;)

Update: Further investigation revealed that the slower performance with Realm is due to the fact that logging in using

logIn(Realm.Credentials.anonymous()).then(() => ...
triggers two Post requests, while
auth.loginWithCredential(new stitch.AnonymousCredential()).then(() => ...
combines authentication and content download into a single request. This results in a TTFB waiting time of 500-700 ms twice with Realm, compared to just once with Stitch.

Answer №1

Currently, I am in the process of building a backend for an application from the ground up using MongoDB Realm. To handle authentication, I have opted to use their Web SDK and specifically utilize email-password credentials. On average, my round-trip performance clocks in at 600-800 ms.

https://i.sstatic.net/W35db.png

Considering my application's Vue frontend, this performance range meets my standards. However, your requirements may differ, so it could be worth exploring the new SDK as an option. Currently, I am experiencing challenges with poor query performance when utilizing Realm's GraphQL endpoint service. As documented in a forum thread that I initiated, their engineers are actively investigating these issues.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

[NodeJS]: Unable to update headers once they have already been sent to the client

For a comprehensive explanation and solution, refer to the initial response here: Error: Can't set headers after they are sent to the client The technology stack I am utilizing includes: Express mongoose (for MongoDB) During the process of register ...

Working with Associated Models in MongoDB using Sails.js

I am utilizing the Waterline ORM within Sails.js to construct a sample application with a model named 'Category'. Since a category can contain multiple subcategories, I have implemented a one-to-many association for this model: module.exports = ...

In Internet Explorer 10, it is not possible to access the document.links using the link's id; it can only be accessed using the

Why does the following code work in FireFox 23.0.1 and Chrome 29, but not in IE 10? <!DOCTYPE html> <html> <head> <title></title> <script type="text/javascript"> function loadFile1(){ a ...

Executing a handler that contains JSX code

I need to display a Loader whenever my page encounters an error and redirects to the Login Page. Here is the code for my Loader component: export const Loader = () => ( <Grid container justify="center" align="center" style={{ height: '100 ...

How effective is Dojo CodeGlass?

When working with Dojo, I have encountered a situation where the sample codes should be functional based on the references provided. However, after attempting to run the code, I am faced with a blank page. It seems as though I may have overlooked somethi ...

Issue: Receiving an error message stating "Text data outside of root node" while attempting to install a

At times, I encounter an error when attempting to install any cordova plugin with Ionic (typically after 6pm GMT+0). These errors occur with plugins sourced from both npm and GitHub, and the message I receive is: Error: Text data outside of root node. Li ...

What is the best way to retrieve the current quality label from JWPlayer using JavaScript?

My goal is to retrieve the Current Quality Label from JWPlayer 7 using JS, but instead of getting the defined labels like 360p, 480p, 720p, I'm only receiving numbers such as 1, 2, 3... This is what I've tried: playerInstance.getCurrentQuality( ...

Transitioning Authentication Code from MongoDB to MySQL in a Node.js Environment

My goal is to implement Oauth2 authentication and I found a GitHub repository that meets my requirements. However, the code in the repository is using MongoDB for the database while I prefer to use MySql. I need help converting the MongoDB authentication ...

What is the proper way to combine two arrays containing objects together?

I am faced with the challenge of merging arrays and objects. Here is an example array I am working with: [ { name: "test", sub: { name: "asdf", sub: {} } }, { name: "models", sub: {} } ] ...

Encountering issues while attempting to execute node-sass using npm

Currently, I'm attempting to execute node-sass using npm. Displayed below is my package.json: { "name": "my-project", "version": "1.0.0", "description": "Website", "main": "index.js", "scripts": { "sass": "node-sass -w scss/ -o dist ...

Discover the position of a dynamically added element

Is there a way to identify the specific dynamically added checkbox that was clicked, whether by index or name? I came across a similar question with a solution in this JSFiddle: JSFiddle Instead of just displaying "clicked", I would like it to show someth ...

What causes useEffect to be triggered multiple times, even when it is dependent on another useEffect function that is being executed repeatedly?

I have a specific requirement that involves using two useEffect hooks. First useEffect is used to set the latitude and longitude in the state with an empty dependency array. useEffect(() => { navigator.geolocation.getCurrentPosition(geo = ...

Struggling with collaborating with an assistant in handlebars and express operations

When attempting to utilize helpers, an error arises: ReferenceError: a is not defined The goal is to display home.hbs located under the views directory. The file contains: <li class="{{#if_eq title "Home"}}active{{/if_eq}}"> <a href="/">H ...

Utilize the information stored in my calculator to input as variables into the chart

I have developed a calculator using JQuery and now I want to pass the calculated results to my Chart JS program so that the chart can dynamically adjust based on new calculations being performed. How do I achieve this with the code below? ** Calculator (J ...

Having difficulty launching a new window within an app built with Electron and Nexjs (Nextron)

Attempting to launch a (Nextjs-generated) page in a new window is causing an error message to appear: Uncaught ReferenceError: global is not defined Here is the full error: react-refresh.js?ts=1665849319975:10 Uncaught ReferenceError: global is not de ...

Using an Ember color picker to dynamically change SCSS variables

Is there a way to allow an admin to change the skin of one of my websites by selecting a color from a palette that will update a universal SASS variable? I am aware of methods to dynamically change CSS using jQuery, but I specifically want to modify the S ...

retrieve image source based on z-index

I found a way to retrieve the z-index value using this code snippet: findHighestZIndex('div'); function findHighestZIndex(elem) { var elems = document.getElementsByTagName(elem); var highest = 0; for (var i = 0; i < elems.length; ...

Vue is tuned in to the input of the enter key

Recently, I created a form component called CreateDocument within my Nuxt project. Along with this component, I also implemented an autocomplete feature known as AutoCompleteFilters. However, I encountered a problem where hitting the enter key inside the ...

Is Wire Protocol the default communication method used by mongoose?

While diving into the MongoDB Wire Protocol, I found myself pondering whether mongoose employs it by default. If not, what steps can we take to integrate it with mongoose? ...

Instant CSS transformation occurs on Safari browser

I am new to coding and trying to learn on my own. I want my code to work smoothly across all popular browsers, starting with Safari. Currently, the -webkit-transition: transform 1.0s; property in my CSS code works instantly in Chrome but not in Safari. Not ...