I've built a web tool using MongoDB databases hosted on Atlas, connected via Stitch . From what I understand, Stitch is now depreciated and has been turned into MongoDB Realm . So I tried to update my site, using the new Realm App instead of Stitch. While it does work, anonymous log-ins are now much slower for some reason. I did some quick testing, using the code suggested in the MongoDB 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 takes me an incredible 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.")
})
With the old Stitch App, it usually takes under 20 ms
to log in.
Any ideas what's going on here or how to solve this? I do know that there is the possibility to first authenticate a user as described in their documentation, however I tried that and it's just as slow.
Is there actually a need to update to the new Realm App, eg will the old Stitch implementation stop working in the not too distant future? Any info on that would be appreciated ;)
Update : I did a bit more investigating, and it seems the reason why Realm is slower comes from the fact that logging in using logIn(Realm.Credentials.anonymous()).then(() => ...
results in two Post requests, but using auth.loginWithCredential(new stitch.AnonymousCredential()).then(() => ...
does the authentication and content download all in one request. With Realm I twice get a 500-700 ms TTFB waiting time, with Stitch that happens just once.
I'm creating an application's backend from scratch with MongoDB Realm currently. I am using their Web SDK to authenticate usingemail-password credentials . My round-trip performance averages around 600-800 ms.
For my application (using a Vue frontend), this is acceptable to me. I don't know what your requirements are, but you may want to try using the new SDK. Unfortunately, I'm encountering poor query performance with the GraphQL endpoint service Realm provides. According to a thread I started on their forum , their engineers are looking into it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.