diff --git a/config/websockets.php b/config/websockets.php index b7ffe7c..28b14b4 100644 --- a/config/websockets.php +++ b/config/websockets.php @@ -214,6 +214,7 @@ return [ 'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger\MemoryStatisticsLogger::class, // 'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger\NullStatisticsLogger::class, + // 'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger\RedisStatisticsLogger::class, /* |-------------------------------------------------------------------------- diff --git a/docs/horizontal-scaling/getting-started.md b/docs/horizontal-scaling/getting-started.md index fffd7fa..3408fff 100644 --- a/docs/horizontal-scaling/getting-started.md +++ b/docs/horizontal-scaling/getting-started.md @@ -32,3 +32,23 @@ Now, when your app broadcasts the message, it will make sure the connection reac The available drivers for replication are: - [Redis](redis) + +## Configure the Statistics driver + +If you work with multi-node environments, beside replication, you shall take a look at the statistics logger. Each time your user connects, disconnects or send a message, you can track the statistics. However, these are centralized in one place before they are dumped in the database. + +Unfortunately, you might end up with multiple rows when multiple servers run in parallel. + +To fix this, just change the `statistics.logger` class with a logger that is able to centralize the statistics in one place. For example, you might want to store them into a Redis instance: + +```php +'statistics' => [ + + 'logger' => \BeyondCode\LaravelWebSockets\Statistics\Logger\RedisStatisticsLogger::class, + + ... + +], +``` + +Check the `websockets.php` config file for more details. diff --git a/docs/horizontal-scaling/redis.md b/docs/horizontal-scaling/redis.md index ee6c758..55020fe 100644 --- a/docs/horizontal-scaling/redis.md +++ b/docs/horizontal-scaling/redis.md @@ -34,4 +34,3 @@ You can set the connection name to the Redis database under `redis`: ``` The connections can be found in your `config/database.php` file, under the `redis` key. It defaults to connection `default`. -