affordablemobiles / GServerlessSupportLaravel

Run Laravel on Google Serverless
MIT License
26 stars 17 forks source link

Handle Session Garbage Collections inside Cloud Functions #70

Closed iamacarpet closed 3 years ago

iamacarpet commented 3 years ago

Session GC has always been a problem as it's slow in PHP (due to the lack of keys only queries and good multi functions), so this seeks to address the problem.

Included is a Cloud Functions that if deployed in the same project will clear sessions older than "SESSION_DURATION" (environment variable needed when deploying the function).

It is designed to be triggered by Cloud Scheduler.

From our testing, it can clear roughly 100 sessions per second.

It is recommended to increase the function execution timeout to the max (540 seconds) and set the maximum execution limit to 1.