Skip to content

Commit 9828df3

Browse files
authored
added documentation for redis sessions
1 parent 51a4732 commit 9828df3

File tree

1 file changed

+49
-7
lines changed

1 file changed

+49
-7
lines changed

README.md

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
## Infrastructure overview
44
* Container 1: MariaDB
5-
* Container 2: Redis (for Magento's cache)
6-
* Container 3: Apache 2.4 + PHP 7.2 (modphp)
7-
* Container 4: Cron
8-
* Container 5: Varnish 5
9-
* Container 6: Redis (for autodiscovery cluster nodes)
10-
* Container 7: Nginx SSL terminator
5+
* Container 2: Redis (volatile, for Magento's cache)
6+
* Container 3: Redis (for Magento's sessions)
7+
* Container 4: Apache 2.4 + PHP 7.2 (modphp)
8+
* Container 5: Cron
9+
* Container 6: Varnish 5
10+
* Container 7: Redis (volatile, cluster nodes autodiscovery)
11+
* Container 8: Nginx SSL terminator
1112

1213
### Why a separate cron container?
1314
First of all containers should be (as far as possible) single process, but the most important thing is that (if someday we'll be able to deploy this infrastructure in production) we may need a cluster of apache+php containers but a single cron container running.
@@ -92,6 +93,46 @@ rm -rf magento2/var/cache/*
9293
```
9394
from now on the var/cache directory should stay empty cause all the caches should be stored in Redis.
9495

96+
## Enable Redis for Magento's sessions
97+
open magento2/app/etc/env.php and replace these lines:
98+
```php
99+
'session' => [
100+
'save' => 'files',
101+
],
102+
```
103+
104+
with these ones:
105+
106+
```php
107+
'session' => [
108+
'save' => 'redis',
109+
'redis' => [
110+
'host' => 'sessions',
111+
'port' => '6379',
112+
'password' => '',
113+
'timeout' => '2.5',
114+
'persistent_identifier' => '',
115+
'database' => '0',
116+
'compression_threshold' => '2048',
117+
'compression_library' => 'gzip',
118+
'log_level' => '3',
119+
'max_concurrency' => '6',
120+
'break_after_frontend' => '5',
121+
'break_after_adminhtml' => '30',
122+
'first_lifetime' => '600',
123+
'bot_first_lifetime' => '60',
124+
'bot_lifetime' => '7200',
125+
'disable_locking' => '0',
126+
'min_lifetime' => '60',
127+
'max_lifetime' => '2592000'
128+
]
129+
],
130+
```
131+
and delete old Magento's sessions with
132+
```
133+
rm -rf magento2/var/session/*
134+
```
135+
95136
## Enable Varnish
96137
Varnish Full Page Cache should already be enabled out of the box (we startup Varnish with the default VCL file generated by Magento2) but you could anyway go to "stores -> configuration -> advanced -> system -> full page cache" and:
97138
* select Varnish in the "caching application" combobox
@@ -139,7 +180,6 @@ Please note that your php.ini will be the last parsed thus you can ovverride any
139180
## TODO
140181
* migrate to alpine/linuxkit based containers?
141182
* optimize everything for docker swarm
142-
* sessions on redis?
143183
* DB clustering?
144184
* optional RabbitMQ
145185

@@ -148,3 +188,5 @@ Please note that your php.ini will be the last parsed thus you can ovverride any
148188
* migrated to docker-compose syntax 3.7
149189
* implemented "delegated" consistency for some of volumes for a better performance
150190
* varnish.vcl was regenerated for Varnish 5 (which was already used since some months)
191+
* 2019-08-06:
192+
* new redis sessions container was added

0 commit comments

Comments
 (0)