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

Redis session handler should not write the session if it has not changed

XMLWordPrintable

    • MOODLE_310_STABLE, MOODLE_400_STABLE
    • MOODLE_310_STABLE
    • MDL-69707-redis-avoid-write
    • Hide

      This is an IO perf issue so you need to compare before and after the patch.

      1) Install a moodle site using the relevant commit for 310 or master:
      master: 46f977a8b (Weekly release, October 6th)
      310: d70cfda57 (On demand October 9th)

      i.e.

      mdk create -t -v master -n mysite
      

      Then, checkout the relevant commit:

      git checkout 5ecd01fb
      

      Then, run through the installation.

      2) Next run redis using docker:

      docker run --net=host --name myredis -d redis
      

      3) Set the session handler to use redis:

      $CFG->session_handler_class = '\core\session\redis';
      $CFG->session_redis_host = '127.0.0.1';
      $CFG->session_redis_port = 6379; // Optional.
      $CFG->session_redis_database = 0; // Optional, default is db 0.
      $CFG->session_redis_prefix = ''; // Optional, default is don't set one.

      Ideally do not put anything else in redis such as MUC to not confound the numbers

      Note: You'll need to also have redis support on your php installation, if you do not already:

      sudo apt-get install php-redis
      sudo service apache2 restart

      4) Shell into your running redis server:

      docker exec -it myredis /bin/bash
      

      5) Run the redis-cli

      redis-cli
      

      6) Purge redis stats from within redis-cli

      config resetstat
      

      7) Now perform a simple pattern such as login, view dashboard, view a specific course, view the calendar, etc.

      Just make sure to remember the pattern of page views you used.

      8) Now look at the redis stats (again from within redis-cli)

      info stats
      

      Look for this field and note the number:
      E.g.
      total_net_input_bytes:117893

      9) Now , checkout master, perform the site upgrade.

      10) Repeat the process in steps 6,7,8 and you should see some drop in inbound IO from the avoided writes.
      Eg an example test run:

      Before the patch:

      total_net_input_bytes:117893
      total_net_output_bytes:85687

      After the patch:

      total_net_input_bytes:85840
      total_net_output_bytes:86600

      Verify there is a drop in total_net_input_bytes when compared to the earlier pre-patch run.

       

       

      Show
      This is an IO perf issue so you need to compare before and after the patch. 1) Install a moodle site using the relevant commit for 310 or master: master: 46f977a8b (Weekly release, October 6th) 310: d70cfda57 (On demand October 9th) i.e. mdk create -t -v master -n mysite Then, checkout the relevant commit: git checkout 5ecd01fb Then, run through the installation. 2) Next run redis using docker: docker run --net=host --name myredis -d redis 3) Set the session handler to use redis: $CFG->session_handler_class = '\core\session\redis' ; $CFG->session_redis_host = '127.0.0.1' ; $CFG->session_redis_port = 6379 ; // Optional. $CFG->session_redis_database = 0 ; // Optional, default is db 0. $CFG->session_redis_prefix = '' ; // Optional, default is don't set one. Ideally do not put anything else in redis such as MUC to not confound the numbers Note: You'll need to also have redis support on your php installation, if you do not already: sudo apt-get install php-redis sudo service apache2 restart 4) Shell into your running redis server: docker exec -it myredis /bin/bash 5) Run the redis-cli redis-cli 6) Purge redis stats from within redis-cli config resetstat 7) Now perform a simple pattern such as login, view dashboard, view a specific course, view the calendar, etc. Just make sure to remember the pattern of page views you used. 8) Now look at the redis stats (again from within redis-cli) info stats Look for this field and note the number: E.g. total_net_input_bytes:117893 9) Now , checkout master, perform the site upgrade. 10) Repeat the process in steps 6,7,8 and you should see some drop in inbound IO from the avoided writes. Eg an example test run: Before the patch: total_net_input_bytes:117893 total_net_output_bytes:85687 After the patch: total_net_input_bytes:85840 total_net_output_bytes:86600 Verify there is a drop in total_net_input_bytes when compared to the earlier pre-patch run.    

      The database handler already does this, but it should just be consistent across all handlers. Possibly it could be moved up into the session manager instead. That feature has been there since MDL-31501

      https://github.com/moodle/moodle/blob/master/lib/classes/session/database.php#L234-L239

            brendanheywood Brendan Heywood
            brendanheywood Brendan Heywood
            Misha Golenkov Misha Golenkov
            Jake Dallimore Jake Dallimore
            Gladys Basiana Gladys Basiana
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 30 minutes
                2h 30m

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