简体   繁体   English

MongoDB Realm 与 Stitch 登录时间 - 为什么 Realm 这么慢?

[英]MongoDB Realm vs. Stitch login times - why is Realm so slow?

I've built a web tool using MongoDB databases hosted on Atlas, connected via Stitch .我使用托管在 Atlas 上的 MongoDB 数据库构建了一个 Web 工具,通过Stitch连接。 From what I understand, Stitch is now depreciated and has been turned into MongoDB Realm .据我了解,Stitch 现在已经贬值,已经变成了MongoDB Realm So I tried to update my site, using the new Realm App instead of Stitch.所以我尝试更新我的网站,使用新的 Realm 应用程序而不是 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:我使用 MongoDB 文档中建议的代码进行了一些快速测试:

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.登录花了我难以置信的1200 ms

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.使用旧的 Stitch 应用程序,登录通常需要不到20 ms

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?实际上是否需要更新到新的 Realm 应用程序,例如,旧的 Stitch 实现会在不久的将来停止工作吗? 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.更新:我做了更多调查,似乎 Realm 速度较慢的原因是使用logIn(Realm.Credentials.anonymous()).then(() => ...导致两个 Post请求,但使用auth.loginWithCredential(new stitch.AnonymousCredential()).then(() => ...在一个请求中完成身份验证和内容下载。使用 Realm 我两次获得 500-700 毫秒的 TTFB 等待时间,使用只发生一次的 Stitch。

I'm creating an application's backend from scratch with MongoDB Realm currently.我目前正在使用 MongoDB Realm 从头开始​​创建应用程序的后端。 I am using their Web SDK to authenticate usingemail-password credentials .我正在使用他们的 Web SDK 使用电子邮件密码凭据进行身份验证。 My round-trip performance averages around 600-800 ms.我的往返性能平均约为 600-800 毫秒。

Chrome DevTools 显示了大约 600 毫秒的 Realm 用户身份验证往返

For my application (using a Vue frontend), this is acceptable to me.对于我的应用程序(使用 Vue 前端),这对我来说是可以接受的。 I don't know what your requirements are, but you may want to try using the new SDK.我不知道您的要求是什么,但您可能想尝试使用新的 SDK。 Unfortunately, I'm encountering poor query performance with the GraphQL endpoint service Realm provides.不幸的是,我在使用 Realm 提供的 GraphQL 端点服务时遇到了糟糕的查询性能。 According to a thread I started on their forum , their engineers are looking into it.根据我在他们的论坛上开始的一个帖子,他们的工程师正在研究它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM