Does Yii's default file session handler cause concurrent request latency only when writing to session?
23K reputation · 30 Nov 2021, 20:33 UTC
Goal: determine whether the extra latency observed under concurrent requests in a Yii application stems solely from write operations to the default file‑based session handler, or whether read‑only session accesses also trigger the same blocking behavior.
With Yii’s default file session component, each request locks the session file for its whole duration, causing subsequent requests that touch the session to wait. It is not documented whether the lock is taken only when the session is written to, or also when it is merely read, and whether disabling auto‑start or initiating the session after the first read changes the lock timing. This uncertainty makes it hard to decide if a custom handler is required for read‑only workloads.
Does a read‑only session still block other requests? Does disabling auto‑start and starting the session lazily after the first read eliminate the lock? Is the latency proportional to the amount of data written to the session?