Architecture - NGRP/node-red-viseo-bot GitHub Wiki
Main concept
The VISEO Bot Maker is a NodeJS web server built on top of IBM Node-RED to build conversation flows. Node-RED use nodes to communicate with 3rd Party APIs using standard protocoles: HTTPs, WSS, File System...
VISEO Bot Maker key
Using the framework requires a valid key, which you can get for free here. The aim for us is to be able to know which versions of the framework are installed, and which packages are most used in order to better prioritize our maintenance efforts.
The usage of this key is not mandatory, you can run the service without having it but we would appreciate that you use it to help us improve our project.
The key is actually used by our most relevant nodes only (servers/connectors, messages, NLP, computer vision, etc.). Data is collected when the input event is triggered. Each day, the following object is sent to our servers:
Hardware
Average chatbots use about 500Mb of RAM and a single vCPU. Developpment server should target this configuration whereas production server should have at least 2 vCPU in order to handle other process and monitor the VM.
Development
- Any computer (Linux, Mac, PC) running NodeJS
- few hundred Mb of Memory
- few Gb of disk.
A development environment like Visual Studio Code and GIT should also be installed.
Production VM
- OS: Any Linux (Ubuntu 14 or 16)
- Processor: 2 vCPU (1 for NodeJS, 1 for monitoring)
- Memory: 1.5Gb (the process use average 500Mb)
- Disk: 10Gb
Architecture
Messages from chatbot client (like Messenger, GoogleHome, Alexa, Website, ...) are sent to Bot Proxy (like MSBotFramework, DialogFlow, Amazon) then redirected to the VISEO Bot Builder. Proxies handle communication with multiple channels.
A single server with NGinx and Let's Encrypt can handle a chatbot on an HTTPs pipe. Otherwise a Failover can be setup to default on a backup server.
Firewalls can't filter IP address from Bot Framework but communication is also secured. Database As A Service like Azure CosmoDB is a good option to handle scalability.
Load Balancer
When a Message perform a prompt, a callback is stored in memory to jump to the next message later. So IP/Session affinity is required for an architecture with a LoadBalancer. On Azure you should use Traffic Manager and an Application Gateway.
SSL Certificate
The front server MUST expose an endpoint sercured by an HTTPs certificate.
- A subdomain MUST bind to server IP to be able to add a certificate
- Let's Encrypt is a free easy option to generate a certificate
Monitoring
Cloud platform provide monitoring of their architecture stack. Otherwise it is recommended to setup monitoring of:
- Server availability
- Server vitals (Memory, CPU, ...)
- NodeJS status (like PM2 and Keymetrics)
- SSL, DDOS, etc...
For intense ChatBot usage it is recommanded to perform benchmarks: Stresstest, Pentest, ...
Scalability
In a Nutshell, Node-RED is an HTTP server (ExpressJS) used to handle data from IoT sensors. It is also distributed on Raspbian (for Raspberry Pi). It is designed to handle a lot of incoming message.
Gatling
Running Gatling with 500 users with an Azure Standard DS2 v2 (2 vcpus, 7 GB memory), on a Node-RED with a 5 questions Message flow will handle 60req/s
- There is a 2000ms timeout (GoogleHome limitation)
- The server do not crash
- If the flow perform heavy action like HTTP request it will downgrade the results