We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41834
    • 3 Posts
    Hi modx users and admins

    As the title names it, the table "modx_sessions" is growing forever and already had a size of 4GB! As we don't need sessions I already tried the following settings, mentioned in another thread, and disabled all sessions in the main context:

    http://develop.modx.com/blog/2012/04/05/new-for-2.2.1-session-less-contexts/

    Now the problem is that preview of unpublished sites isn't working anymore. I think that makes sense if there's a "security function" for unpublished sites based on a valid session.

    Has anybody an idea why the session table isn't cleared or where I can take a look why it fails? Or is it alternatively possible to create a context that doesn't include preview sites?

    Please excuse my english, I'm not a native speaker. If someone needs more information, please ask.

    Thanks in advance and kind regards, Marius

    _________________

    And at last the requested information, at least where it makes sense and is relevant to the problem:

    Web Server:
    * --> Running behind a bigip F5 LB!
    * PHP version and how it's running (suexec, mod_php, CGI, etc.) --> 5.3.3 / mod_php
    * Apache or IIS version --> Apache 2.2.16
    * Operating System and version --> Debian 6


    Database:
    * MySQL version --> 5.1.63
    * List of any tables over 1MB in size --> modx_site_content / modx_session


    MODx:
    * Version --> 2.2.2
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      There is definitely garbage collection happening on the session table. If you have a lot of visitors, the table might grow large though. 4GB is a bit insane, I'll give you that smiley

      If you just open up the table, and find the oldest record (there's a timestamp column in there), please verify that it is exactly-ish 7 days old - the default time for sessions to be kept in the database.

      If you get a lot of visitors, it can help to lower the session time by lowering the session_gc_maxlifetime and session_cookie_lifetime settings.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 41834
        • 3 Posts
        Hi Mark

        Thanks for your fast answer.

        There are only the columns "id", "access" and "data" (sequel pro GUI, I'm not a specialist for mysql). I see 40'000 entries in the modx_session table since yesterday resulting in ~250MB data table and nearly the same for the index. One of the strange things is that we don't have this amount of visitors in one week!

        Ok, back to start. If we have more then 500MB per day, it seems possible to reach the 4GB (MID and MYI files together).

        Why does modx open multiple times more sessions then we have visitors? And I agree, it is insane smiley

        regards, Marius

          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Your server's access logs might be interesting to examine. Are you actually getting this many requests from distinct domains? Is somebody from one domain with cookies disabled hammering the site, causing a new session at each request? Is something internally malfunctioning, starting multiple sessions for each request?
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 10487 MODX Staff
            • 1,535 Posts
            Hi Marius, there is still a chance, that even if sessions in that table have expired and are ready for garbage collection, they may not be garbage-collected immediately.

            This is because PHP does not call garbage collection on each and every request (unless you specifically set it to) but rather runs on a percentage determined by two garbage collection settings in your php.ini - these are: session.gc_probability and session.gc_divisor where the percentage chance of PHP calling garbage collection is session.gc_probability/session.gc_divisor. In most default cases, this could be 1%.

            I would do as Mark says and first check the oldest timestamp in the modx_session table to see exactly when it dates from. Also, you could try tweaking the session.gc_probability setting if you have access to the php.ini to increase the percentage that PHP will call garbage collection if this is proving to be a problem.
              Garry Nutting
              Senior Developer
              MODX, LLC

              Email: [email protected]
              Twitter: @garryn
              Web: modx.com
              • 41834
              • 3 Posts
              Hi everybody

              We found it!

              It was the health monitor from the loadbalancer that caused the unexpected sessions. I'll observe the session table and hope it will be stable after a week. BTW; I didn't get it the first time that the "access" column is a UNIX timestamp ;-)

              Thanks to everybody, it helped a lot to understand what's going on.

              regards, Marius

                • 54165
                • 1 Posts
                Quote from: ml_dswiss at Oct 30, 2012, 12:06 AM
                Hi everybody

                We found it!

                It was the health monitor from the loadbalancer that caused the unexpected sessions. I'll observe the session table and hope it will be stable after a week. BTW; I didn't get it the first time that the "access" column is a UNIX timestamp ;-)

                Thanks to everybody, it helped a lot to understand what's going on.

                regards, Marius


                *bump*

                Hi Marius,

                Would you mind sharing what you did to resolve this? I'm in the process of setting up a load balancer with MODX and I'm concerned about the health check from our load balancer ballooning this table out of control. I've scoured Google and haven't found a good answer. Is there a way to prevent the load balancer from creating a new session every time it performs a health check, or is the only solution to increase the frequency of garbage collection and shortening the life of the session to less than 1 week?

                Thanks!