microsoft-orleans , dotnet-core ,

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

by Abhith Rajan FollowApril 24, 2019 · 1 min read · Last Updated:
Share this

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

private static async Task Main(string[] args)
    int siloPort, gatewayPort;
        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();

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

dotnet run <siloPort> <gatewayPort>


dotnet run 11111 30000
dotnet run 11112 30001
dotnet 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 FollowBuy 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