microsoft-orleans | dotnet-core

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.

Abhith Rajan
Abhith RajanApril 24, 2019 · 2 min read · Last Updated:

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

1private static async Task Main(string[] args)
2{
3 int siloPort, gatewayPort;
4 try
5 {
6 siloPort = int.Parse(args[0]);
7 gatewayPort = int.Parse(args[1]);
8 }
9 catch (Exception)
10 {
11 siloPort = 11111;
12 gatewayPort = 30000;
13 }
14
15 var invariant = "System.Data.SqlClient"; // for Microsoft SQL Server
16 var connectionString = "Data Source=.;Initial Catalog=OrleansCluster;Integrated Security=True;Pooling=False;Max Pool Size=200;MultipleActiveResultSets=True";
17
18 var siloBuilder = new SiloHostBuilder()
19 // Clustering information
20 .Configure<ClusterOptions>(options =>
21 {
22 options.ClusterId = "dev";
23 options.ServiceId = "ServiceApp";
24 })
25 .UseAdoNetClustering(options =>
26 {
27 options.Invariant = invariant;
28 options.ConnectionString = connectionString;
29 })
30 .ConfigureEndpoints(siloPort: siloPort, gatewayPort: gatewayPort)
31
32 .ConfigureLogging(logging => logging.AddConsole());
33
34 using (var host = siloBuilder.Build())
35 {
36 await host.StartAsync();
37 Console.ReadLine();
38 }
39}

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

1dotnet run <siloPort> <gatewayPort>

eg,

1dotnet run 11111 30000
2dotnet run 11112 30001
3dotnet run 11113 30002

Abhith Rajan

Written by Abhith Rajan
Abhith Rajan is an aspiring software engineer with more than nine years of experience and has a proven successful track record of delivering technology-based products and services.
Connect

This page is open source. Noticed a typo? Or something unclear?
Improve this page on GitHub

Related ArticlesView All

Related VideosView All

Alex Thissen - Logging, tracing and metrics: instrumenting your .NET Core based cloud applications

Clustering in Orleans

Distributed Tracing Made Easy with .NET Core - Jimmy Bogard

Related StoriesView All