Hello, We have a problem regarding Domain.Build method. our application is a Multi-tenancy Cloud ERP system, the system consists of a master database and a company database for each tenant, we have two application, the web site which hosts the business application and a desktop application to manage the tenants in term of update version and so on (which requires the build of the database according to the version model). the problem is the memory usage and time consumed which raise during the build of the company's model (tenant model), it consumes a lot of memory which reaches over 1 GB if running as 64 bit application (in IIS or windows form application), if running as 32 bit application it may decreased nearly to the half. also it takes nearly 2:3 Minutes to complete the build of the domain (in addition to the overhead it puts on SQL Server which is SQL Server 2008 R2).

I have sent this problem before as a question but the solution didn't fix it completely, as our application wasn't as the same size as now (in terms of functionality and entity objects), now building the domain reflects in a huge number of tables being created or checked in the database. http://support.x-tensive.com/question/5178/domain-memory-usage-problem

Also we had a problem before regarding an OutOfMemoryException which solved by force the application to run under 64 bit process and .net 4.5 (desktop application) according to your suggestion here: http://support.x-tensive.com/question/6217/domain-build-systemoutofmemoryexception

We have also some minor problem, but the two mentioned before is argent as we have an Internet service provider who is waiting to solve them before we can host our application on his Infrastructure.

We use DataObjects.net V4.6.4 on SQL Server 2008 R2 / Windows 64 bit (7 & Server 2008 R2)

asked Apr 19 '15 at 02:24

ahmad%20emad's gravatar image

ahmad emad
26292931

edited Apr 19 '15 at 08:22

Hello ahmad emad.

In which modes do you build domains?

(Apr 20 '15 at 06:47) Alexey Kulakov Alexey%20Kulakov's gravatar image

Hello Alexy, From the application manager(window forms 64 bit) we use Perform to update the structure and the version, from website itself we use Validate

(Apr 21 '15 at 03:22) ahmad emad ahmad%20emad's gravatar image

I wrote you email. Check it.

(Apr 22 '15 at 06:06) Alexey Kulakov Alexey%20Kulakov's gravatar image

ahmad emad. I wrote you email on e-mail address which in your profile. I think discussion via skype would be more quicker and more affective. Please, contact me.

(Apr 27 '15 at 03:51) Alexey Kulakov Alexey%20Kulakov's gravatar image

One Answer:

Hello Ahmad. Unfortunately, I have bad news for you.

I've analyzed another versions of DO on your model. I built one Master domain and three Company domains and max memory usage was about 1.3-1.4 GB for four domains. But, unfortunately, no one of 4.6.x can decrease memory usage for you. I couldn't compare 4.6.4 with 5.0.x because of breaking changes in some APIs in 5.0.x. We'll try to decrease memory in next 5.0.6-5.0.7 versions of DO. 4.6 version is no longer developed.

Some advices for you:

  1. As I've told you, use Skip mode instead of Validate when it possible. This mode is fastest (except legacy modes maybe) building mode. If you are sure that domain model isn't changed I strongly recommend you this mode. Models are not compared in Skip. In 5.0.4 we decrease memory usage (maybe not so much but it's true) due to model from storage is no longer extracted.
  2. Use perform mode only if you have some changes of model. Maybe you can upgrade your databases one by one if your memory usage is limited.
  3. For new databases use Recreate mode. In this mode Domain builds in one stage (Perform and PerformSafely in two stages).

5.0.x have a StorageNodeManager. It allows you unite several databases in one big domain, but only if they have the same model. They use one model so memory usage on domain less then in case of several domains

It works like that. You have many databases with the same model and you need sometimes more than one of them (I think it's exactly your case) When you need first domain than you build it as normal domain. Just first of them. Then you need to connect another one. You configure Storage node and add it to domain you already have. Thanks to they have one model building process gets already created model and use it for operations.

Add new storage node:


// you have already built domain
//configuring
var nodeConfiguration = new NodeConfiguration("<unique identifier of node>");
nodeConfiguration.ConnectionInfo = new ConnectionInfo("<connection to node>");
nodeConfiguration.UpgradeMode = DomainUpgradeMode.Perform;//or another mode you need

//add storage node to domain domain.StorageNodeManager.Add(nodeConfiguration);

Querying to specified node


using (var session = domain.OpenSession())
using (var tx = session.OpenTransaction()) {
  session.SelectStorageNode(<unique identifier of one of nodes>);
  //your queries will be passed to node you specified
}

answered Apr 28 '15 at 04:36

Alexey%20Kulakov's gravatar image

Alexey Kulakov
77225

edited Sep 09 '15 at 10:28

I can add that we successfully use StorageNodeManager from DO v5 to run approximately 1K domains on a set of 8GB machines hosting multitentant ASP.NET MVC application.

(Apr 28 '15 at 06:28) Alex Yakunin Alex%20Yakunin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA