-
Notifications
You must be signed in to change notification settings - Fork 0
Load Balancer
@jmgasper Yes, It works with multiple Vanilla instances. I found an article, it has been written for a long time, but it includes useful tips (https://open.vanillaforums.com/discussion/17716/how-does-vanilla-scale).
Running multiple Vanilla instances There are two options:
-
Multiple Vanilla instances under the same DB but using a different table prefix for each Vanilla Instance. Each Vanilla instance should set a table prefix: $Configuration['Database']['DatabasePrefix'] = 'GDN_'
-
Multiple Vanilla instances under the same DB but using the same tables. Implemented this one.
Multiple Vanilla instances under the same DB but using the same tables
Docker compose runs:
- one load balancer inctance. It is configured with a proxy module that forwards all incoming requests to the corresponding Vanilla instances.
- one mysql DB
- one memcached
- two Vanilla instances, both calling the same database and memcached
How to start it
-
clone the forum repo
-
overwrite all files forums_files.zip - The archive contains only new/changed files.
-
run docker commands:
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
-
Go to the first Vanilla instance and install Vanilla: The first Vanilla Instance - http://172.20.128.4. Disable the OAuth2 plugin, if you don't want to use it.
-
Copy Vanilla config from the first Vanilla instance to the second Vanilla instance:
docker cp vanilla-local1:/vanillapp/conf/config.php .
docker cp ./config.php vanilla-local2:/vanillapp/conf/config.php
After copying config.php use only http://127.0.0.1/ to connect via the load balancer
- Go to Vanilla http://127.0.0.1/
View the load balancer statistics - http://127.0.0.1/balancer-manager:
- Run
docker stop vanilla-local1
to stop one server instance.
Visit Vanilla pages and go to the load balncer statistics.
You should see 'Init Err' for 'http://172.20.128.4' but you can connect to the Vanilla forum.
Important notes
-
Config.php Some settings are saved into config.php, others in DB. If the file is not shared between the servers, then there may be unforeseen behavior if the administrator changes the settings. config.php should be shared between all instances after Vanilla Installation. Set 'PATH_CONF_DEFAULT' (PATH_CONF.'/config.php' is used by default.) for a shared location.
-
Session Vanilla uses cookie-based sessions.
Cookies configuration: $Configuration['Garden']['Cookie']['Salt'] = ''; // We do this during setup $Configuration['Garden']['Cookie']['Name'] = 'Vanilla'; $Configuration['Garden']['Cookie']['Path'] = '/'; $Configuration['Garden']['Cookie']['Domain'] = ''; $Configuration['Garden']['Cookie']['HashMethod'] = 'md5'; // md5 or sha1
The cookies settings are saved into config.php.
- Synchronizing the uploads Vanilla Instance 1 uploads an image/document/attachment. It is stored in local Vanilla uploads directory. If Users log into Vanilla through Vanilla Instance 2 obviously the image cannot be found as it is sitting on Vanilla Instance 1.
Assuming we'll have a static assets server (AWS S3), we can set the PATH_UPLOADS constant in our bootstrap file to point to that AWS S3. The last thing to figure out is how to make /uploads use the remote service (like AWS S3). Need a plugin to route file uploads to an S3 bucket, and to use that S3 bucket's URL when rendering them. The plugin should totally control the saving/moving/deleting of files.
- Memcached
"Vanilla has support for both Memcache and Memcached, but we strongly recommend Memcached if you have an option. It does require additional configuration beyond installing and enabling it in PHP. (https://success.vanillaforums.com/kb/articles/220-configuring-the-webserver)"
Check memcached used: echo "stats settings" | nc "172.20.128.2" 11211 echo "stats cachedump 3 100" | nc "172.20.128.2" 11211
Let me know if you have any questions.