Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Load Balancer for HTTP Only

Bogdan Marian edited this page Oct 10, 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.

  1. Go to Rancher UI
  2. Create 2 stacks based on DokuWiki catalog item
    1. The first one was created while performing 07 - Create a Stack
    2. The second one should only contain minor differences
  3. Wait for the second stack to be created and started, then you should see they are running on different hosts
  4. Go to menu → Stacks → User
  5. Click "Add Stack" button
  6. Fill in the fields accordingly
    1. Name: load-balancer
    2. Description: Load balancer to be used by all tgd environment services.
  7. Click "Create" button
  8. From the stack top right menu, select "Add Load Balancer Service"
  9. Fill in the fields accordingly
    1. Add a Service Rule
      1. Access: Public
      2. Protocol: HTTP
      3. Request Host: leave empty
      4. Port: 80
      5. Path: /
      6. Target: dokuwiki-server from stack dokuwiki1
      7. Port: 80 (this is the container internal port, where its Apache process will listen for any incoming requests)
    2. Add another Service Rule with the same fields, just change Target to dokuwiki-server from stack dokuwiki2
  10. Click the "Create" button
  11. This will fail, since we have 2 services on a host, trying to use the same port 80
  12. Update both DokuWiki services to use a different HTTP port: 8081, respectively 8082
  13. Go to menu → Stacks → User
  14. Click the dokuwiki-server link from dokuwiki1 stack
  15. From the service top right menu, click "Upgrade"
  16. Change only one field: Public Host Port to 8081, then click "Upgrade" button
  17. Rancher will stop the container of the existing service and will create another one with the new settings
  18. Click the service top right menu → Finish Upgrade; this will remove the old container
  19. Do the same for dokuwiki-server link from dokuwiki2 stack; set Public Host Port field to 8082
  20. The load balancer service should be running OK by now
  21. Click the "80/tcp" link from its Port field to navigate to one DokuWiki instance
  22. 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
  23. Go to dokuwiki-server service from dokuwiki1 stack and click the Host IP link associated with Port 8081
  24. Create a page inside the DokuWiki instance
  25. Add one phrase using Heading 1: DokuWiki Instance #1
  26. Do the same for dokuwiki-server service from dokuwiki2 stack, just change the phrase to "DokuWiki Instance #2"
  27. 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
Clone this wiki locally