RavenDb 和多租户

发布于 2024-12-03 19:37:29 字数 591 浏览 0 评论 0原文

我已经研究并使用了 RavenDb 一段时间,并开始考虑 MultiTenancy。多租户的 Ayendes 示例如下所示:

using(var store = new DocumentStore
{
    Url = "http://localhost:8080"
}.Initialize())
{
    store.DatabaseCommands.EnsureDatabaseExists("Brisbane");

    store.DatabaseCommands.EnsureDatabaseExists("Melbroune");
    store.DatabaseCommands.EnsureDatabaseExists("Sidney");

    using (var documentSession = store.OpenSession("Brisbane"))
    {
        documentSession.Store(new { Name = "Ayende"});
        documentSession.SaveChanges();
    }
}

我不知道每个数据库是如何存储的,因此问题是:这适用于拥有大量租户的大型应用程序吗?

I have looked and played around with RavenDb for a while and have started to look at MultiTenancy. Ayendes sample for multitenancy looks like this:

using(var store = new DocumentStore
{
    Url = "http://localhost:8080"
}.Initialize())
{
    store.DatabaseCommands.EnsureDatabaseExists("Brisbane");

    store.DatabaseCommands.EnsureDatabaseExists("Melbroune");
    store.DatabaseCommands.EnsureDatabaseExists("Sidney");

    using (var documentSession = store.OpenSession("Brisbane"))
    {
        documentSession.Store(new { Name = "Ayende"});
        documentSession.SaveChanges();
    }
}

I don't know how each database is stored and hence the question: Will that work for large applications with a lot of tenants?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白鸥掠海 2024-12-10 19:37:29

请参阅文档的第一段和最后一段(v2.5 | v3.0)。

RavenDB 的数据库在设计时就考虑到了多租户,并且
旨在在单个服务器上支持大量数据库。在
为了做到这一点,RavenDB 将只保持活动数据库打开。如果
您第一次访问数据库时,该数据库将被打开
并开始,因此对该数据库的下一个请求无需付费
打开数据库的成本。但如果数据库还没有
访问一段时间后,RavenDB会清理所有关联的资源
与数据库并关闭它。

这使得 RavenDB 能够管理大量数据库,因为
在任何给定时间,只有活动数据库实际占用
资源。

所以是的,它将支持它,并且每个数据库将存储在磁盘上的单独文件夹中。

See the first and last paragraphs from the docs (v2.5 | v3.0).

RavenDB's databases were designed with multi tenancy in mind, and are
meant to support large number of databases on a single server. In
order to do that, RavenDB will only keep the active databases open. If
you access a database for the first time, that database will be opened
and started, so the next request to that database wouldn't have to pay
the cost of opening the database. But if a database hasn't been
accessed for a while, RavenDB will cleanup all resources associated
with the database and close it.

That allows RavenDB to manage large numbers of databases, because at
any given time, only the active databases are actually taking
resources.

So yes it will support it and each database will be stored in a separate folder on disk.

习惯成性 2024-12-10 19:37:29

实施多租户(加上混合组合)有 3 个基本选项:
输入图片此处的描述

一切都可以放入 RavenDB(最初的问题是关于选项#2)。当然,完全隔离租户的选项#1 更安全,但从长远来看,其他选项可能会变得更便宜,而选项#3 是这三种选项中最实惠的(从长远来看)。

查看这些资源:

There are 3 basic options of implementing multi-tenancy (plus hybrid combinations):
enter image description here

All are good to go in RavenDB (the original question was about option #2). Of course, option #1 with fully isolated tenants is more secure but others are likely to become cheaper in the long run with option #3 being the most affordable out of the three (in the long run).

Check out these resources:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文