-
Task
-
Resolution: Unresolved
-
Major
-
3.3.15
-
None
Ticket number for this PR: https://github.com/phpbb/phpbb/pull/6383
Background:
I had a DDoS attack on login form. It quickly filled the sessions table with tens of thousands of sessions for the anonymous user. A lot of sessions for this user dramatically decreased the performance of SELECT COUNT(session_id) AS sessions FROM SESSIONS_TABLE ... query, since the efficiency of session_user_id index was almost non-existent (99% of sessions was for anonymous user, so the query needed to count almost all rows in table). I excluded this query for the anonymous user, since it was not needed anyway. This significantly improved performance of forum, but...
...sessions were still created and the sessions table was growing. I ignored this, but after a few days I realized that cron does not work correctly. It turns out that task for clearing old sessions tried to load hundreds of thousands of sessions in one query, which exceeded the memory limit, and the whole process failed (and this was repeated over and over since old sessions were never removed). I added a limit to this query, so sessions could be cleaned up in smaller batches (I'm still not sure if this limit is optimal, but it worked for me).

