-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Member Roles
doc
#5742
Add Member Roles
doc
#5742
Changes from 8 commits
a81c258
4563c2c
5de627d
210ae39
d7de54a
8529d77
876a5b4
76ff75a
a2374d4
400bec0
66a4b6f
82a4380
6fee097
dbd5dd5
aad9f44
854d723
a300b06
3bc1939
ae9a01f
fca18c5
d16ea43
c8ab363
43d8791
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
uid: member-roles | ||
title: Member Roles | ||
--- | ||
|
||
# Member Roles | ||
|
||
![cluster roles](/images/cluster-roles.png) | ||
|
||
A cluster can have multiple Akka.NET applications in it, "roles" help to distinguish different Akka.NET applications within a cluster! | ||
Not all Akka.NET applications in a cluster need to perform the same function. For example, there might be one sub-set which runs the web front-end, one which runs the data access layer and one for the number-crunching. | ||
Choosing which actors to start on each node, for example cluster-aware routers, can take member roles into account to achieve this distribution of responsibilities. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something needs to be said about usage of roles being a best practice. There isn't a good reason not to do it. Just come out and say this along the following lines:
|
||
|
||
## How to Use Role Information in Akka.NET | ||
|
||
The member roles are defined in the configuration property named `akka.cluster.roles` and typically defined in the start script as a system property or environment variable.: | ||
|
||
```hocon | ||
akka { | ||
cluster { | ||
roles = ["backend"] | ||
} | ||
} | ||
``` | ||
### Programming Against Akka.Cluster Events | ||
|
||
The roles are part of the membership information in `MemberEvent` that you can subscribe to. The roles of the local cluster member are available from the `SelfMember` and that can be used for conditionally starting certain actors: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
```csharp | ||
var selfMember = Cluster.Get(_actorSystem).SelfMember; | ||
if (selfMember.HasRole("backend")) | ||
{ | ||
context.ActorOf(Backend.Prop(), "back"); | ||
} | ||
else if (selfMember.HasRole("front")) | ||
{ | ||
context.ActorOf(Frontend.Prop(), "front"); | ||
} | ||
``` | ||
|
||
### Akka.Cluster.Sharding | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to make all headers consistent - either code formatted or regular text, not a blend of both |
||
|
||
```hocon | ||
akka { | ||
cluster { | ||
roles = ["worker", "notifier", "credit", "storage"] | ||
sharding { | ||
role = "worker" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And what does this do for Akka.Cluster.Sharding? |
||
} | ||
} | ||
} | ||
``` | ||
|
||
### `DistributedPubSub` | ||
|
||
```hocon | ||
akka { | ||
cluster { | ||
roles = ["worker", "notifier", "credit", "storage"] | ||
pub-sub { | ||
role = "notifier" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And what does this do for DistributedPubSub? |
||
} | ||
} | ||
} | ||
``` | ||
|
||
### `DData` | ||
|
||
```hocon | ||
akka { | ||
cluster { | ||
roles = ["worker", "notifier", "credit", "storage"] | ||
distributed-data { | ||
role = "storage" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And what does this do for DData? |
||
} | ||
} | ||
} | ||
``` | ||
|
||
|
||
### `ClusterSingleton` | ||
|
||
```hocon | ||
akka { | ||
cluster { | ||
roles = ["worker", "notifier", "credit", "storage"] | ||
singleton { | ||
role = "credit" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And what does this mean for Cluster Singleton? |
||
} | ||
} | ||
} | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,6 @@ | |
- name: Distributed Data | ||
href: distributed-data.md | ||
- name: Split Brain Resolver | ||
href: split-brain-resolver.md | ||
href: split-brain-resolver.md | ||
- name: Member Roles | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this much closer to the top - as this is a critical, fundamental concept to clustering. Also, link to this page from the cluster overview early on. |
||
href: member-roles.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this image should probably be moved into a "cluster" sub folder, rather than the root images folder. Don't want to clutter that up.