# ActivationCountBasedPlacement

Package: [Microsoft.Orleans.Core.Abstractions](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/) 10.0.0

[NuGet package](https://www.nuget.org/packages/Microsoft.Orleans.Core.Abstractions) | [Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Core.Abstractions/Placement/ActivationCountBasedPlacement.cs#L23)

```csharp
[Orleans.GenerateSerializer]
[Orleans.Immutable]
[Orleans.SuppressReferenceTracking]
public sealed class ActivationCountBasedPlacement : PlacementStrategy
```

A placement strategy which attempts to achieve approximately even load based upon the number of recently-active grains on each server.

## Remarks

The intention of this placement strategy is to place new grain activations on the least heavily loaded server based on the number of recently busy grains. It includes a mechanism in which all servers periodically publish their total activation count to all other servers. The placement director then selects a server which is predicted to have the fewest activations by examining the most recently reported activation count and a making prediction of the current activation count based upon the recent activation count made by the placement director on the current server. The director selects a number of servers at random when making this prediction, in an attempt to avoid multiple separate servers overloading the same server. By default, two servers are selected at random, but this value is configurable via `Orleans.Runtime.ActivationCountBasedPlacementOptions`.  This algorithm is based on the thesis The Power of Two Choices in Randomized Load Balancing by Michael David Mitzenmacher [https://www.eecs.harvard.edu/~michaelm/postscripts/mythesis.pdf](https://www.eecs.harvard.edu/~michaelm/postscripts/mythesis.pdf), and is also used in NGINX for distributed load balancing, as described in the article NGINX and the "Power of Two Choices" Load-Balancing Algorithm [https://www.nginx.com/blog/nginx-power-of-two-choices-load-balancing-algorithm/](https://www.nginx.com/blog/nginx-power-of-two-choices-load-balancing-algorithm/).  This placement strategy is configured by adding the [ActivationCountBasedPlacementAttribute](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.placement.activationcountbasedplacementattribute/) attribute to a grain.

## Constructors

- [ActivationCountBasedPlacement](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.activationcountbasedplacement/constructors/constructor-bffd23a5/)
