Nevermind, I just found the solution after too much forums and try-error (I always find the solution after asking, it doesn’t matter if I spend a whole day trying it before, it’s asking and hitting the nail on the head)
Architecture:
-
Instance 1:
- nginx container (load balancer and reverse proxy)
- redis container (rasa servers will connect to this db in 6379 port)
-
Instance 2:
- rasa server container
- rasa actions container
-
Instance 3:
- rasa server container
- rasa actions container (i have to see if i can set only one action server)
Docker-compose redis file:
version: '3.0'
services:
redis:
image: redis:latest
container_name: redis
ports:
- 6379:6379
Now, each rasa server endpoint has to set this configuration:
tracker_store:
type: redis
url: load-balancer-ip (preferable the internal ip, where the redis container is deployed)
port: 6379
db: 1
password: (yes, this is empty, no authentication will be done)
lock_store:
type: redis
url: load-balancer-ip (preferable the internal ip, where the redis container is deployed)
port: 6379
db: 0
password:
key_prefix: rasa
#tracker_store:
# type: sql
Then, when you start both rasa server, the nginx and redis containers, you can access to the redis container with:
- docker exec -it id /bin/bash
Then run:
Once in redis interface, run
- select 1 (this is the tracker database)
Run:
Now you will see all the tracker id of the user who talked to the bot, you can see the conversation with:
In this way, although the telegram request is balanced between the servers, the database will be unified and therefore, each user will have a record of their history, allowing interactions not to be mixed
Kudos to Rasa course, rasa training, rasa interview, docker tracker store redis service deployment of Rasa practical series
Also, for bonus configuration, this is my nginx configuration (i know i can do it better)
#/etc/nginx/conf.d/default.conf
upstream lb {
include servers;
}
# http access with reverse proxy
server {
listen 80;
# reverse proxy
location / {
proxy_pass http://lb;
}
}
# https access with reverse proxy
server {
listen 443 ssl;
# set ssl certificates for https access
ssl_certificate /etc/letsencrypt/live/your-ld-domain/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your-ld-domain/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/your-ld-domain/fullchain.pem;
# reverse proxy
location / {
proxy_pass http://lb;
}
}
- servers file (the include reference)
server ip-1:5005;
server ip-2:5005;
The ssl certificates has been created with certbot and letscrypt, you will need to use a domain (aws ec2 domains does not work Policy forbids issuing for name on Amazon EC2 domain - #4 by jsha - Server - Let's Encrypt Community Support)
It would be nice if someone can confirm this solution to mark it as Solution, as anyone has responded the thread yet
Regards, Raúl.