Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-63128

Redis Cache & Session: implement cluster support

Details

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_36_STABLE, MOODLE_404_STABLE
    • MDL-63128-main
    • Hide

      Setup Requirements

      1. To test the Redis cluster with other features that have been provided by the existing system, such as TLS/SSL, Auth Password, please follow the instructions on Usage section at https://github.com/meirzamoodle/middleware-tutorials-redis-cluster-tls/tree/main#usage
      2. Ensure your machine has the PHP-Redis extension by checking on the Info PHP page. There are a lot of ways to check the PHP Info Page. Moodle has provided it on the Site Admin > Server > PHP info.
        If it has not been installed, you can install it by running the below command:

        pecl install redis

        Please visit https://developer.redis.com/develop/php/ for detailed information on how to do the installation.

      3. The testing will involve Redis CLI using a shell/terminal to trigger a failure on one of the nodes.

      Redis Testing Performance and failover testing.

      1. Run the docker compose command to activate the Redis Cluster (Setup requirements number one)
      2. Log in as admin
      3. Navigate to Site Admin > Plugins > Caching > Cache Stores > Redis
      4. Tick the Cluster Mode checkbox
      5. Specify the Test server with the below IP addresses
        172.23.0.11
        172.23.0.12
        172.23.0.13
        172.23.0.14
        172.23.0.15
        172.23.0.16
      6. Tick the Use TLS encryption checkbox
      7. Specify the path of the CA file where you are cloning the Redis Cluster docker image. For instance, if you are cloning at "/home/moodle/middleware-tutorials-redis-cluster-tls", the file path for CA is "/home/moodle/middleware-tutorials-redis-cluster-tls/tls/ca.crt".
      8. Specify the Test server password with foobared
      9. Click the Save canges button.
      10. Verify that there is a success notification with the words "Changes saved".
      11. Navigate to Site Admin > Plugins > Caching > Test performance
      12. Select whatever number of requests you want to test with
      13. Verify that there is no error warning
      14. Verify that on the Redis row, the result column has "tested" label.
      15. Now we will do the failover testing. Open your shell/terminal.
      16. Run the below command:

        redis-cli -a foobared -h 172.23.0.11 --tls --cacert /home/moodle/middleware-tutorials-redis-cluster-tls/tls/ca.crt

      17. In the Redis CLI prompt, run the below command:

        debug segfault

      18. Verify that you will see the message "Error: Server closed the connection". That means that the node with IP address 172.23.0.11 is down.
      19. Return to the browser. Navigate to Site Admin > Plugins > Caching > Test performance.
      20. If you see an error warning like the below messages:
        > The Redis Cluster is down (CLUSTERDOWN)
        > Timed out attempting to find data in the correct node!
        Please keep reload the Test performance page until those messages disappear, my machine needs 20-30 seconds to get normal, the time can vary depending on the machine. After some time verify that there is no error warning.

      Cache Store Testing

      1. Run the docker compose command to activate the Redis Cluster (Setup requirements number one)
      2. Log in as admin
      3. Navigate to Site Admin > Plugins > Caching > Configuration
      4. Click the Add Instance link in the Redis row
      5. Specify the Store name with Redis cluster store
      6. Tick the Cluster Mode checkbox
      7. Specify the servers with the below IP addresses
        172.23.0.11
        172.23.0.12
        172.23.0.13
        172.23.0.14
        172.23.0.15
        172.23.0.16
      8. Tick the Use TLS encryption checkbox
      9. Specify the path of the CA file where you are cloning the Redis Cluster docker image. For instance, if you are cloning at "/home/moodle/middleware-tutorials-redis-cluster-tls", the file path for CA is "/home/moodle/middleware-tutorials-redis-cluster-tls/tls/ca.crt".
      10. Specify the password with foobared
      11. Click the Save canges button.
      12. Verify that there is a success notification "Successfully added a new Redis store. "
      13. Verify that in the Redis stores column, there is a value 1
      14. Go to the bottom of the page
      15. Click "Edit mappings" link
      16. For the Application and Session dropdowns, select "Redis cluster store"
      17. Click the Save changes button.
      18. Verify that there is no error warning
      19. At the Configured store instances, click the Purge link at the Redis cluster store row
      20. Verify that there is a successfull notification "Successfully purged the "Redis cluster store" store. Purge again"

      Session Testing

      1. Run the docker compose command to activate the Redis Cluster (Setup requirements number one)
      2. Edit the config.php and add the below lines:

        $CFG->session_handler_class = '\core\session\redis';
        $CFG->session_redis_host = '172.23.0.11,172.23.0.12,172.23.0.13,172.23.0.14,172.23.0.15,172.23.0.16';
        $CFG->session_redis_auth = 'foobared';
        $CFG->session_redis_encrypt = ['cafile' => '/home/moodle/middleware-tutorials-redis-cluster-tls/tls/ca.crt'];

      3. Return to the browser.
      4. Reload the web page.
      5. Verify that there is no error warning.
      Show
      Setup Requirements To test the Redis cluster with other features that have been provided by the existing system, such as TLS/SSL, Auth Password, please follow the instructions on Usage section at https://github.com/meirzamoodle/middleware-tutorials-redis-cluster-tls/tree/main#usage Ensure your machine has the PHP-Redis extension by checking on the Info PHP page. There are a lot of ways to check the PHP Info Page. Moodle has provided it on the Site Admin > Server > PHP info. If it has not been installed, you can install it by running the below command: pecl install redis Please visit https://developer.redis.com/develop/php/ for detailed information on how to do the installation. The testing will involve Redis CLI using a shell/terminal to trigger a failure on one of the nodes. Redis Testing Performance and failover testing. Run the docker compose command to activate the Redis Cluster (Setup requirements number one) Log in as admin Navigate to Site Admin > Plugins > Caching > Cache Stores > Redis Tick the Cluster Mode checkbox Specify the Test server with the below IP addresses 172.23.0.11 172.23.0.12 172.23.0.13 172.23.0.14 172.23.0.15 172.23.0.16 Tick the Use TLS encryption checkbox Specify the path of the CA file where you are cloning the Redis Cluster docker image. For instance, if you are cloning at " /home/moodle/middleware-tutorials-redis-cluster-tls ", the file path for CA is " /home/moodle/middleware-tutorials-redis-cluster-tls/tls/ca.crt ". Specify the Test server password with foobared Click the Save canges button. Verify that there is a success notification with the words "Changes saved". Navigate to Site Admin > Plugins > Caching > Test performance Select whatever number of requests you want to test with Verify that there is no error warning Verify that on the Redis row, the result column has "tested" label. Now we will do the failover testing. Open your shell/terminal. Run the below command: redis-cli -a foobared -h 172.23 . 0.11 --tls --cacert /home/moodle/middleware-tutorials-redis-cluster-tls/tls/ca.crt In the Redis CLI prompt, run the below command: debug segfault Verify that you will see the message "Error: Server closed the connection". That means that the node with IP address 172.23.0.11 is down. Return to the browser. Navigate to Site Admin > Plugins > Caching > Test performance. If you see an error warning like the below messages: > The Redis Cluster is down (CLUSTERDOWN) > Timed out attempting to find data in the correct node! Please keep reload the Test performance page until those messages disappear, my machine needs 20-30 seconds to get normal, the time can vary depending on the machine. After some time verify that there is no error warning. Cache Store Testing Run the docker compose command to activate the Redis Cluster (Setup requirements number one) Log in as admin Navigate to Site Admin > Plugins > Caching > Configuration Click the Add Instance link in the Redis row Specify the Store name with Redis cluster store Tick the Cluster Mode checkbox Specify the servers with the below IP addresses 172.23.0.11 172.23.0.12 172.23.0.13 172.23.0.14 172.23.0.15 172.23.0.16 Tick the Use TLS encryption checkbox Specify the path of the CA file where you are cloning the Redis Cluster docker image. For instance, if you are cloning at " /home/moodle/middleware-tutorials-redis-cluster-tls ", the file path for CA is " /home/moodle/middleware-tutorials-redis-cluster-tls/tls/ca.crt ". Specify the password with foobared Click the Save canges button. Verify that there is a success notification "Successfully added a new Redis store. " Verify that in the Redis stores column, there is a value 1 Go to the bottom of the page Click "Edit mappings" link For the Application and Session dropdowns, select "Redis cluster store" Click the Save changes button. Verify that there is no error warning At the Configured store instances, click the Purge link at the Redis cluster store row Verify that there is a successfull notification "Successfully purged the "Redis cluster store" store. Purge again" Session Testing Run the docker compose command to activate the Redis Cluster (Setup requirements number one) Edit the config.php and add the below lines: $CFG->session_handler_class = '\core\session\redis' ; $CFG->session_redis_host = '172.23.0.11,172.23.0.12,172.23.0.13,172.23.0.14,172.23.0.15,172.23.0.16' ; $CFG->session_redis_auth = 'foobared' ; $CFG->session_redis_encrypt = [ 'cafile' => '/home/moodle/middleware-tutorials-redis-cluster-tls/tls/ca.crt' ]; Return to the browser. Reload the web page. Verify that there is no error warning.
    • 6
    • Team Hedgehog 2023 Sprint 4.3, Team Hedgehog 2023 Review 4, Team Hedgehog 2024 Sprint 1.1, Team Hedgehog 2024 Sprint 1.2

    Description

      Based on https://tracker.moodle.org/browse/MDL-59880

      Implements support for clustered redis.

      Attachments

        1. test_1.png
          test_1.png
          138 kB
        2. test_2.png
          test_2.png
          303 kB

        Issue Links

          Activity

            People

              meirza.arson@moodle.com Meirza
              roperto Daniel Thee Roperto
              Safat Shahin Safat Shahin
              Votes:
              31 Vote for this issue
              Watchers:
              40 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 weeks, 2 days, 4 hours, 11 minutes
                  2w 2d 4h 11m

                  Clockify

                    Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.