A Firestore-backed session driver for Laravel, designed to run smoothly on Google App Engine (Standard environment).
composer require firevel/firestore-session-driverApp Engine (app.yaml):
env_variables:
SESSION_DRIVER: firestore
# Optional: tune GC batch size (see "Garbage collection & scale")
# SESSION_GC_BATCH_SIZE: 500Local development (.env):
SESSION_DRIVER=firestore
# SESSION_GC_BATCH_SIZE=500Firestore credentials on App Engine Standard are picked up via Application Default Credentials. For local development, set
GOOGLE_APPLICATION_CREDENTIALSif needed.
Configure the session lifetime as usual in config/session.php or via .env:
SESSION_LIFETIME=120Firestore session cleanup happens via Laravel’s session lottery. On very high-traffic apps this can be a bottleneck. You can tune or offload it:
- Adjust the lottery in
config/session.php(note the correct path/key):'lottery' => [2, 100], // e.g., 2% chance per request
- Batch size: control how many expired sessions are removed per GC pass:
SESSION_GC_BATCH_SIZE=500
- Heavy load / HA setups: consider moving GC out of request flow. Run cleanup on a schedule (cron/Scheduler) and set a very low lottery, or temporarily switch to the
cookiedriver if GC becomes a hotspot.
In extreme cases, run garbage collection from a scheduled job/cron and reduce the in-request lottery to near zero.
- Review Firestore’s quotas and limits before deploying high-throughput workloads: https://cloud.google.com/firestore/quotas