orleans icon indicating copy to clipboard operation
orleans copied to clipboard

The question of Orleans memory?

Open zhanlanghun opened this issue 8 years ago • 6 comments

Why does the amount of memory that goes into my Orleans service go up all the way to about 500M?

code: siloHost = new SiloHostBuilder() .Configure(options => { options.ClusterId = clusterId; options.ServiceId = serviceId;

          })
             .UsePerfCounterEnvironmentStatistics()
           // .UseEnvironment(environment)
            //.ConfigureHostConfiguration(option=> {

            //})
            // .ConfigureEndpoints(System.Net.Dns.GetHostName(), int.Parse(siloPort), int.Parse(gatewayPort))
            .Configure<EndpointOptions>(options =>
            {
                options.AdvertisedIPAddress = GetLocalIp();// IPAddress.Parse("192.168.11.143") ;
                options.GatewayPort = int.Parse(gatewayPort);
                options.SiloPort = int.Parse(siloPort);
            })
          //.Configure<LoadSheddingOptions>(op =>
          //{
          //    op.LoadSheddingEnabled = true;
          //    op.LoadSheddingLimit = 90;
          //})
          .Configure<GrainCollectionOptions>(options =>
          {
              //配置grain的回收
              options.CollectionAge = TimeSpan.FromMinutes(10);
              options.CollectionQuantum = TimeSpan.FromMinutes(5);
          })
          //.Configure<PerformanceTuningOptions>(option =>
          //{
          //    option.UseNagleAlgorithm = true;
          //    option.MinDotNetThreadPoolSize = 90;
          //})

          .UseAdoNetClustering(options =>
          {
              options.ConnectionString = DBConnStr;
              options.Invariant = "System.Data.SqlClient";
          })
          // .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IProduct).Assembly).WithReferences())
          .ConfigureLogging(logging =>
          {
              logging.AddFile(logPath + $"\\OrleansSilos -{ DateTime.Now.ToString("yyyy.MM.dd")}.txt");
              logging.SetMinimumLevel((LogLevel) Enum.Parse(typeof(LogLevel), logLevel));
          })
          .Build();
        siloHost.StartAsync().Wait();

zhanlanghun avatar Jun 04 '18 03:06 zhanlanghun

I suspect this is just the normal behavior of .NET garbage collector - in the absence of memory pressure it lazily collects memory, which may be rather infrequent.

sergeybykov avatar Jun 06 '18 22:06 sergeybykov

@sergeybykov
Thank you for your reply I found that the memory size is different on different machines, for example, the local machine is 100 meters, and the other machine is 400 meters. Does Orleans have a mechanism for allocating memory in advance?

zhanlanghun avatar Jun 07 '18 04:06 zhanlanghun

Orleans doesn't explicitly allocate any memory other than for messaging buffers and stream provider caches. Number of CPU cores on the machine influences how many threads Orleans runtime creates, and that implicitly impacts the memory footprint.

I think though that all of that is no significant enough for a 4x difference between two machines, and just the normal behavior of the .NET memory manager explains temporary differences.

If you really want to investigate, take memory dumps from those two machines and compare them.

sergeybykov avatar Jun 08 '18 00:06 sergeybykov

@zhanlanghun @sergeybykov I have also a weird memory bump here.

When I launch a silo (the silo is doing nothing more than responding to some ping every few seconds)

  • the memory consumption is already around 200MB ... ok it's a lot for nothing but it's ok.

Then I launch an other silo (the one that actually sending the pings, from another cluster so it have a brand new IClusterClient ... actually)

  • the memory consumption goes around 400 MB ... it's a lot for sending few pings ! image

I did few tests, It cost about 200 MB to run each clusterclient (can goes up to 700 MB for a silo and 2 more cluster clients in a single processus for example).

Is it the reason why heterogenous cluster exists ? Since this discussion (https://github.com/dotnet/orleans/issues/5320) I gave up on having all grains available from all the silos and rather decided to have one silo per grain type. This will lead my "facade to all grains api" to need 2GB memory for handling 10 grain types :-| ?

jrouaix avatar Jan 30 '19 12:01 jrouaix

Is this just an artefact of managed memory? .NET memory manager can allocate quite a bit of object before performing a collection pass. Because of that, just looking the OS level memory counters is usually misleading.

sergeybykov avatar Jan 30 '19 18:01 sergeybykov

Closing due to inactivity - plus I think this is answered

ReubenBond avatar Jan 14 '20 18:01 ReubenBond