Re: many sessions wait on LWlock WALWrite suddenly - Mailing list pgsql-performance

From MichaelDBA
Subject Re: many sessions wait on LWlock WALWrite suddenly
Date
Msg-id 54f2f74e-6574-b337-84cc-0281405ce5da@sqlexec.com
Whole thread Raw
In response to many sessions wait on LWlock WALWrite suddenly  (James Pang <jamespang886@gmail.com>)
List pgsql-performance
LWLock always shows up in the case where you have too many concurrent active connections.  Do a select from the pg_stat_activity table where state in ('idle in transaction','active'); Then count how many CPUs you have.  If the sql query count returned is greater than 2-3 times the number of CPUs, you probably have a CPU overload problem and your solution may be to add a connection pooler between the client and the DB server.  This is all due to the nature of how PG is architected: every connection is a process, not a thread.

Regards,
Michael Vitale

James Pang wrote on 4/11/2025 10:36 AM:
   pgv14.8 , during peak time, we suddenly see hundreds of active sessions waiting on LWlock  WALWrite at the same time, but we did not find any issue on storage .
any suggestions ? 

Thanks,

James


Regards,

Michael Vitale

Michaeldba@sqlexec.com

703-600-9343 


Attachment

pgsql-performance by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: many sessions wait on LWlock WALWrite suddenly
Next
From: James Pang
Date:
Subject: session waiting IO while background writer writing data