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

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

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_310_STABLE, MOODLE_400_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE
    • Pull 3.10 Branch:
      MDL-69707-redis-avoid-write-MOODLE_310_STABLE
    • Pull Master Branch:
      MDL-69707-redis-avoid-write
    • Testing Instructions:
      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.    

      Description

      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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              brendanheywood Brendan Heywood
              Reporter:
              brendanheywood Brendan Heywood
              Peer reviewer:
              Mikhail Golenkov Mikhail Golenkov
              Integrator:
              Jake Dallimore Jake Dallimore
              Tester:
              Gladys Basiana Gladys Basiana
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                9/Nov/20

                  Time Tracking

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