mod_logged performance optimize in big sites

Discussion regarding Joomla! 4.x Performance issues.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Post Reply
Vrut
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed May 15, 2024 3:23 pm

mod_logged performance optimize in big sites

Post by Vrut » Wed May 15, 2024 3:29 pm

Hi Joomla 4.4.4
Big site with 130 000 rows is table #__session

administrator/modules/mod_logged/src/Helper/LoggedHelper.php


ROW 45

Code: Select all

        $query = $db->getQuery(true)
            ->select('s.time, s.client_id, u.id, u.name, u.username')
            ->from('#__session AS s')
            ->join('LEFT', '#__users AS u ON s.userid = u.id')
            ->where('s.guest = 0')
            ->setLimit($params->get('count', 5), 0);
Replace it with this:

Code: Select all

        $query = $db->getQuery(true)
            ->select('s.time, s.client_id, u.id, u.name, u.username')
            ->from('#__session AS s')
            ->join('INNER', '#__users AS u ON s.userid = u.id')
            ->where('s.guest = 0 AND s.userid > 0')
            ->setLimit($params->get('count', 5), 0);

Original code load when you go to administration
/administrator/index.php

after login 5.2 seconds... (module latest logged users)
New code load admin in 160 ms.

Ad this code to all Joomla for better performance.

Thanks
Last edited by toivo on Wed May 15, 2024 9:27 pm, edited 1 time in total.
Reason: mod note: typo in subject

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31093
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: mod_logged performence optimize in big sites

Post by Per Yngve Berg » Wed May 15, 2024 5:02 pm

Better to change Session Handler from 'database' to 'filesystem' to let php handle the Sessions rather than the database.

Vrut
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed May 15, 2024 3:23 pm

Re: mod_logged performance optimize in big sites

Post by Vrut » Fri May 17, 2024 4:32 pm

Hi Per Yngve Berg,
i send for joomla community(developers) code to fix not optimized sql query thats the point...

And in big sites is not good had 130 000 files in 1 folder.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31093
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: mod_logged performance optimize in big sites

Post by Per Yngve Berg » Fri May 17, 2024 4:56 pm

Vrut wrote: Fri May 17, 2024 4:32 pm And in big sites is not good had 130 000 files in 1 folder.
The PHP Session are always created so the files is present anyway. Only the User specific data is moved to the database.

Vrut
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed May 15, 2024 3:23 pm

Re: mod_logged performance optimize in big sites

Post by Vrut » Fri May 17, 2024 7:47 pm

But still in my first topic is code witch change joomla performance from 5.2 second to 160ms so it's good to add this changed code to joomla core files.

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 12811
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: mod_logged performance optimize in big sites

Post by brian » Fri May 17, 2024 10:06 pm

Per Yngve Berg wrote: Fri May 17, 2024 4:56 pm
Vrut wrote: Fri May 17, 2024 4:32 pm And in big sites is not good had 130 000 files in 1 folder.
The PHP Session are always created so the files is present anyway. Only the User specific data is moved to the database.
Per - That is not true. Try it for yourself. Set to filesystem and the path to your tmp folder. Log in and out a few times.
Check the folder and you will have one file for each of the times you logged in. Now set to database. Delete those session files and log in and out a few times. Check the folder and you will not have any session files.

@vrut in joomla 4 you should b4e using the provided System - Session Data Purge plugin and in Joomla 5 you should be using the provided schedule task to purge the expired session and do a garbage clean up. I find it hard to believe there are 130k active sessions.
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

Vrut
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed May 15, 2024 3:23 pm

Re: mod_logged performance optimize in big sites

Post by Vrut » Sat May 18, 2024 5:51 pm

brian wrote: Fri May 17, 2024 10:06 pm @vrut in joomla 4 you should b4e using the provided System - Session Data Purge plugin and in Joomla 5 you should be using the provided schedule task to purge the expired session and do a garbage clean up. I find it hard to believe there are 130k active sessions.

We save session for 10 days... Soo thats the reason why we have 130 000 session in 10 days... 13 000/per day.

But still point is somebody who is Joomla developer: it will be better change this not optimized SQL query to query which i send.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2992
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: mod_logged performance optimize in big sites

Post by SharkyKZ » Sat May 18, 2024 6:09 pm

It's a valid suggestion. Alternative would be to add an index on guest column. Currently, there is combined index for guest and client_id columns. Anyways, you should report this on the issue tracker https://github.com/joomla/joomla-cms/issues.


Post Reply

Return to “Performance - Joomla! 4.x”