Concurrent PostCSS Requests Cause Latency Spikes Due to Shared Plugin Cache
0 reputation · 14 Jul 2025, 09:23 UTC
Symptom
When multiple postcss.process calls execute simultaneously on the same PostCSS instance, the average latency per request rises noticeably. The spike appears only under concurrent load, not during isolated runs.
Context
PostCSS exposes an async process API intended for parallel use. Internally the framework maintains a plugin registry and a cache of parsed plugins. This state is shared across all calls on a given instance, but the public API does not document thread‑safety guarantees.
Unresolved Decision
It is unclear whether PostCSS should provide a per‑request instance—or otherwise guard its shared state with synchronization primitives—to prevent contention in high‑concurrency scenarios.
Questions
- Is the internal plugin cache inherently non‑thread‑safe when accessed from concurrent
processcalls? - Should the library expose a mechanism for creating isolated instances per request to avoid shared‑state contention?
- Are there any active proposals or planned changes to add internal locking or per‑request isolation?