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 · 1 min read · Last Updated:

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 byAbhith Rajan
Abhith Rajan is a software engineer by day and a full-stack developer by night. He's coding for almost a decade now. He codes 🧑‍💻, write ✍️, learn 📖 and advocate 👍.

Is this page helpful?

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