laravel-websockets/docs/horizontal-scaling/redis.md

43 lines
828 B
Markdown
Raw Normal View History

2020-08-18 12:29:49 +00:00
---
2020-09-11 06:25:13 +00:00
title: Redis Mode
2020-08-18 12:29:49 +00:00
order: 2
---
2020-09-11 06:25:13 +00:00
# Redis Mode
2020-08-18 12:29:49 +00:00
2020-09-11 06:25:13 +00:00
Redis has the powerful ability to act both as a key-value store and as a PubSub service. This way, the connected servers will communicate between them whenever a message hits the server, so you can scale out to any amount of servers while preserving the WebSockets functionalities.
## Configure Redis mode
To enable the replication, simply change the `replication.mode` name in the `websockets.php` file to `redis`:
2020-08-18 12:29:49 +00:00
```php
'replication' => [
2020-09-11 06:25:13 +00:00
'mode' => 'redis',
2020-08-18 12:29:49 +00:00
...
],
```
You can set the connection name to the Redis database under `redis`:
```php
'replication' => [
2020-09-11 06:25:13 +00:00
'modes' =>
'redis' => [
2020-08-18 12:29:49 +00:00
2020-09-11 06:25:13 +00:00
'connection' => 'default',
2020-08-18 12:29:49 +00:00
2020-09-11 06:25:13 +00:00
],
2020-08-18 12:29:49 +00:00
],
],
```
2020-09-11 06:25:13 +00:00
The connections can be found in your `config/database.php` file, under the `redis` key.