microsoft-orleans | dotnet-core

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

by Abhith RajanApril 24, 2019 · 2 min read · Last Updated:
Share this

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

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

Abhith Rajan

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

Related Videos