Re: many sessions wait on LWlock WALWrite suddenly

From: MichaelDBA <MichaelDBA(at)sqlexec(dot)com>
To: James Pang <jamespang886(at)gmail(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: many sessions wait on LWlock WALWrite suddenly
Date: 2025-04-11 22:43:10
Message-ID: 54f2f74e-6574-b337-84cc-0281405ce5da@sqlexec.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sqlexec(dot)com <mailto:michaelvitale(at)sqlexec(dot)com>

703-600-9343

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message James Pang 2025-04-14 05:30:07 session waiting IO while background writer writing data
Previous Message Laurenz Albe 2025-04-11 19:59:29 Re: many sessions wait on LWlock WALWrite suddenly