Scaling & Redundancy

  • Hey!

    I'm currently working on a project that's exploring the option of using Pagekit as the CMS behind it but we're assessing the scaling and redundancy options before we go ahead with it. For starters, why does the /tmp/sessions/ folder exist, are these part of the PHP sessions or a different implementation that we should know about for potential HA options such as storing in redis/memcache?


    If anyone's worked on a Pagekit site that utilises multiple servers with load balancers or similar, tips and ideas would be greatly appreciated. Thanks in advance!

  • SPQRInc

    Approved the thread.
  • I can give you some hints as I don't know much about Pagekit's session handling.


    Here the session provider is registered. Looks like there is a File and a Database Handler:

    /pagekit/app/modules/session/index.php


    In /pagekit/app/system/app.php the config file /pagekit/app/system/config.php is loaded with the following session config:

    What I currently don't understand, why the configure the files path if the use the database handler:

    Hope this hints helps.

    The LORD is my strength and my shield; in him my heart trusts, and I am helped; my heart exults, and with my song I give thanks to him. Psalm 28,7

  • Thanks for your reply! This is what we were confused about too as we saw the /tmp/sessions/ folder and then the sessions table in the database too so we were a little unsure as to which is used, or if both are used and required? We're just looking to make sure that we have things in place to ensure that we've some redundancy and that we're able to scale somewhat!

  • I just checked some websites. I can confirm, Pagekit uses both, the database and the files. The files are matching the entries in the table.


    I guess, if session is started or continued, it's config is read from the database and cached into /tmp/sessions for further use. But that is just a hypothesis.

    The LORD is my strength and my shield; in him my heart trusts, and I am helped; my heart exults, and with my song I give thanks to him. Psalm 28,7

  • Thanks again for looking into this for us :-) This doesn't sound ideal then, sadly. Are you aware of any way we can potentially disable the session handling that Pagekit seems to have implemented and use PHP's own? As this implementation of sessions looks like it would be a bit of a hassle to work with in terms of replicating across multiple machines/load balancing, whereas PHP's own session handling would be handled a lot easier?

  • I think I got it. Pagekit is purly using the DatabaseSessionHandler after its installation. The files I found in /tmp/sessions were old file which were created during the installation of pagekit. The installer itself cannot use the database, as it is not yet set up. In app/installer/config.php which is loaded in app/installer/app.php the session storage is set to array. That will default to the NativeFileSessionHandler. But after installation, pagekit in started with app/system/app.php loading app/system/config.php with session storage to database.


    Then I think, it's no problem to scale things up ;).


    P.S The Session itself is an implementation of the Symfony Session. Check https://symfony.com/doc/curren…_foundation/sessions.html

    The LORD is my strength and my shield; in him my heart trusts, and I am helped; my heart exults, and with my song I give thanks to him. Psalm 28,7