title | description | ms.date |
---|---|---|
Typical configurations |
Learn about typical configurations in .NET Orleans. |
08/18/2023 |
Below are examples of typical configurations that can be used for development and production deployments.
For more information, see Local development configuration.
For a reliable production deployment using Azure, you need to use the Azure Table option for cluster membership. This configuration is typical of deployments to either on-premises servers, containers, or Azure virtual machine instances.
The format of the DataConnection
string is a ;
separated list of Key=Value
pairs. The following options are supported:
Key | Value |
---|---|
DefaultEndpointsProtocol |
https |
AccountName |
<Azure storage account> |
AccountKey |
<Azure table storage account key> |
The following is an example of a DataConnection
string for Azure Table storage:
"DefaultEndpointsProtocol=https;AccountName=<Azure storage account>;AccountKey=<Azure table storage account key>"
Silo configuration:
const string connectionString = "YOUR_CONNECTION_STRING_HERE";
var silo = new HostBuilder()
.UseOrleans(builder =>
{
.Configure<ClusterOptions>(options =>
{
options.ClusterId = "Cluster42";
options.ServiceId = "MyAwesomeService";
})
.UseAzureStorageClustering(
options => options.ConfigureTableServiceClient(connectionString))
.ConfigureEndpoints(siloPort: 11_111, gatewayPort: 30_000)
.ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Warning).AddConsole())
})
.Build();
Client configuration:
const string connectionString = "YOUR_CONNECTION_STRING_HERE";
var client = new ClientBuilder()
.Configure<ClusterOptions>(options =>
{
options.ClusterId = "Cluster42";
options.ServiceId = "MyAwesomeService";
})
.UseAzureStorageClustering(
options => options.ConfigureTableServiceClient(connectionString))
.ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Warning).AddConsole())
.Build();
For a reliable production deployment using SQL server, a SQL server connection string needs to be supplied.
Silo configuration:
const string connectionString = "YOUR_CONNECTION_STRING_HERE";
var silo = new HostBuilder()
.UseOrleans(builder =>
{
.Configure<ClusterOptions>(options =>
{
options.ClusterId = "Cluster42";
options.ServiceId = "MyAwesomeService";
})
.UseAdoNetClustering(options =>
{
options.ConnectionString = connectionString;
options.Invariant = "System.Data.SqlClient";
})
.ConfigureEndpoints(siloPort: 11111, gatewayPort: 30000)
.ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Warning).AddConsole())
})
.Build();
Client configuration:
const string connectionString = "YOUR_CONNECTION_STRING_HERE";
var client = new ClientBuilder()
.Configure<ClusterOptions>(options =>
{
options.ClusterId = "Cluster42";
options.ServiceId = "MyAwesomeService";
})
.UseAdoNetClustering(options =>
{
options.ConnectionString = connectionString;
options.Invariant = "System.Data.SqlClient";
})
.ConfigureLogging(builder => builder.SetMinimumLevel(LogLevel.Warning).AddConsole())
.Build();
For testing on a cluster of dedicated servers when reliability isn't a concern you can leverage MembershipTableGrain
and avoid dependency on Azure Table. You just need to designate one of the nodes as a primary.
On the silos:
var primarySiloEndpoint = new IPEndpoint(PRIMARY_SILO_IP_ADDRESS, 11_111);
var silo = new HostBuilder()
.UseOrleans(builder =>
{
builder
.UseDevelopmentClustering(primarySiloEndpoint)
.Configure<ClusterOptions>(options =>
{
options.ClusterId = "Cluster42";
options.ServiceId = "MyAwesomeService";
})
.ConfigureEndpoints(siloPort: 11_111, gatewayPort: 30_000)
.ConfigureLogging(logging => logging.AddConsole())
})
.Build();
On the clients:
var gateways = new IPEndPoint[]
{
new IPEndPoint(PRIMARY_SILO_IP_ADDRESS, 30_000),
new IPEndPoint(OTHER_SILO__IP_ADDRESS_1, 30_000),
// ...
new IPEndPoint(OTHER_SILO__IP_ADDRESS_N, 30_000),
};
var client = new ClientBuilder()
.UseStaticClustering(gateways)
.Configure<ClusterOptions>(options =>
{
options.ClusterId = "Cluster42";
options.ServiceId = "MyAwesomeService";
})
.ConfigureLogging(logging => logging.AddConsole())
.Build();