Microsoft Orleans - Run Multiple Silos from a .NET Core Console App

If you are new to Microsoft Orleans and you are in a stage where you want to run multiple Silo from a single .NET Core console app, here is a way to achieve that.

commit 40dc58d · authored · 1 min read

Microsoft Orleans - Run Multiple Silos from a .NET Core Console App

My Silo Host project Program.cs Main method looks like below,

private static async Task Main(string[] args)
{
int siloPort, gatewayPort;
try
{
siloPort = int.Parse(args[0]);
gatewayPort = int.Parse(args[1]);
}
catch (Exception)
{
siloPort = 11111;
gatewayPort = 30000;
}
var invariant = "System.Data.SqlClient"; // for Microsoft SQL Server
var connectionString = "Data Source=.;Initial Catalog=OrleansCluster;Integrated Security=True;Pooling=False;Max Pool Size=200;MultipleActiveResultSets=True";
var siloBuilder = new SiloHostBuilder()
// Clustering information
.Configure<ClusterOptions>(options =>
{
options.ClusterId = "dev";
options.ServiceId = "ServiceApp";
})
.UseAdoNetClustering(options =>
{
options.Invariant = invariant;
options.ConnectionString = connectionString;
})
.ConfigureEndpoints(siloPort: siloPort, gatewayPort: gatewayPort)
.ConfigureLogging(logging => logging.AddConsole());
using (var host = siloBuilder.Build())
{
await host.StartAsync();
Console.ReadLine();
}
}

To run multiple Silo, we need to specify different set of ports for each. Here we are achieving the same via parsing the args.

Now you can run a Silo by executing following command on the Silo project root directory

Terminal window
dotnet run <siloPort> <gatewayPort>

eg,

Terminal window
dotnet run 11111 30000
dotnet run 11112 30001
dotnet run 11113 30002

local graph · open full graph

"Microsoft Orleans - Run Multiple Silos from a .NET Core Console App" is connected to the topics Microsoft Orleans, .NET Core and related to 4 other entries. .NET Core - NuGet Packages CI & CD Using GitHub Actions .NET Core - NuGet Packages … Azure DevOps Build - Could not locate the assembly Azure DevOps Build - Could … Using AutoMapper in a .NET Core Class Library Using AutoMapper in a .NET … .netstandard2.0 Project - DocFX MSBuild Error .netstandard2.0 Project - D… Microsoft Orleans #microsoft-orleans .NET Core #dotnet-core Microsoft Orleans - Run Multiple …

comments

loading discussion…