This repository has been archived by the owner on Aug 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Load Balancer for HTTP Only
satrapu edited this page Oct 14, 2017
·
7 revisions
This page details how to setup a load balancer to distribute HTTP requests made against several instances of DokuWiki hosted on a running instance of Rancher server.
More information can be found here.
- Go to Rancher UI
- Create 2 stacks based on DokuWiki catalog item
- The first one was created while performing 07 - Create a Stack
- The second one should only contain minor differences
- Wait for the second stack to be created and started, then you should see they are running on different hosts
- Go to menu → Stacks → User
- Click "Add Stack" button
- Fill in the fields accordingly
- Click "Create" button
- From the stack top right menu, select "Add Load Balancer Service"
- Fill in the fields accordingly
- Add a Service Rule
- Access: Public
- Protocol: HTTP
- Request Host: leave empty
- Port: 80
- Path: /
- Target: dokuwiki-server from stack dokuwiki1
- Port: 80 (this is the container internal port, where its Apache process will listen for any incoming requests)
- Add another Service Rule with the same fields, just change Target to dokuwiki-server from stack dokuwiki2
- Add a Service Rule
- Click the "Create" button
- This will fail, since we have 2 services on a host, trying to use the same port 80
- Update both DokuWiki services to use a different HTTP port: 8081, respectively 8082
- Go to menu → Stacks → User
- Click the dokuwiki-server link from dokuwiki1 stack
- From the service top right menu, click "Upgrade"
- Change only one field: Public Host Port to 8081, then click "Upgrade" button
- Rancher will stop the container of the existing service and will create another one with the new settings
- Click the service top right menu → Finish Upgrade; this will remove the old container
- Do the same for dokuwiki-server link from dokuwiki2 stack; set Public Host Port field to 8082
- The load balancer service should be running OK by now
- Click the "80/tcp" link from its Port field to navigate to one DokuWiki instance
- Refresh page several times and you'll see you cannot tell which DokuWiki instance is in fact serving the request, so we need to visit each DokuWiki instance and create a page with a specific title to be used as a discriminator
- Go to dokuwiki-server service from dokuwiki1 stack and click the Host IP link associated with Port 8081
- Create a page inside the DokuWiki instance
- Add one phrase using Heading 1: DokuWiki Instance #1
- Do the same for dokuwiki-server service from dokuwiki2 stack, just change the phrase to "DokuWiki Instance #2"
- Go back to the load balancer URL and refresh the page several times; you should notice that each request is processed by a different DokuWiki instance, thus the load balancer is working and it's using the round-robin algorithm