pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedDoes idle sessions will consume more cpu and ram? If yes,how to control them
7+ messages / 6 participants
[nested] [flat]
* Does idle sessions will consume more cpu and ram? If yes,how to control them
@ 2018-12-18 03:45 Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-12-20 00:32 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Joshua White <joshua.white@monash.edu>
0 siblings, 1 reply; 7+ messages in thread
From: Raghavendra Rao J S V @ 2018-12-18 03:45 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
In my application, the idle sessions are consuming cpu and ram. refer the
ps command output.
How idle session will consume more ram/cpu?
How to control it?
We are using Postgresql 9.2 with Centos 6 os. Please guide me.
[image: image.png]
--
Regards,
Raghavendra Rao J S V
Mobile- 8861161425
Attachments:
image.png (image/png, 103.8K) download
view image
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Does idle sessions will consume more cpu and ram? If yes,how to control them
2018-12-18 03:45 Does idle sessions will consume more cpu and ram? If yes,how to control them Raghavendra Rao J S V <raghavendrajsv@gmail.com>
@ 2018-12-20 00:32 ` Joshua White <joshua.white@monash.edu>
2018-12-20 01:27 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 7+ messages in thread
From: Joshua White @ 2018-12-20 00:32 UTC (permalink / raw)
To: Raghavendra Rao J S V <raghavendrajsv@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
>
> In my application, the idle sessions are consuming cpu and ram. refer the
> ps command output.
>
If you connect to the database, does select * from pg_stat_activity() show
a lot of idle connections?
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Does idle sessions will consume more cpu and ram? If yes,how to control them
2018-12-18 03:45 Does idle sessions will consume more cpu and ram? If yes,how to control them Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-12-20 00:32 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Joshua White <joshua.white@monash.edu>
@ 2018-12-20 01:27 ` Michael Paquier <michael@paquier.xyz>
2018-12-20 01:41 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Michael Paquier @ 2018-12-20 01:27 UTC (permalink / raw)
To: Joshua White <joshua.white@monash.edu>; +Cc: Raghavendra Rao J S V <raghavendrajsv@gmail.com>; pgsql-general@lists.postgresql.org
On Thu, Dec 20, 2018 at 11:32:22AM +1100, Joshua White wrote:
>> In my application, the idle sessions are consuming cpu and ram. refer the
>> ps command output.
>>
>
> If you connect to the database, does select * from pg_stat_activity() show
> a lot of idle connections?
Each backend stores its own copy of the relation cache, so if you have
idle connections which have been used for other work in the past then
the memory of those caches is still around. Idle connections also have
a CPU cost in Postgres when building snapshots for example, and their
entries need to be scanned from a wider array, but usually the relation
cache bloat is a wider problem. This can be countered with pgbouncer as
connection pooling.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Does idle sessions will consume more cpu and ram? If yes,how to control them
2018-12-18 03:45 Does idle sessions will consume more cpu and ram? If yes,how to control them Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-12-20 00:32 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Joshua White <joshua.white@monash.edu>
2018-12-20 01:27 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Michael Paquier <michael@paquier.xyz>
@ 2018-12-20 01:41 ` Ron <ronljohnsonjr@gmail.com>
2018-12-20 03:34 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Ron @ 2018-12-20 01:41 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 12/19/18 7:27 PM, Michael Paquier wrote:
[snip]
> Each backend stores its own copy of the relation cache, so if you have
> idle connections which have been used for other work in the past then
> the memory of those caches is still around. Idle connections also have
> a CPU cost in Postgres when building snapshots for example, and their
> entries need to be scanned from a wider array, but usually the relation
> cache bloat is a wider problem.
So it's best to kill connections that have been idle for a while?
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Does idle sessions will consume more cpu and ram? If yes,how to control them
2018-12-18 03:45 Does idle sessions will consume more cpu and ram? If yes,how to control them Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-12-20 00:32 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Joshua White <joshua.white@monash.edu>
2018-12-20 01:27 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Michael Paquier <michael@paquier.xyz>
2018-12-20 01:41 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Ron <ronljohnsonjr@gmail.com>
@ 2018-12-20 03:34 ` Pavel Stehule <pavel.stehule@gmail.com>
2018-12-20 04:01 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Joshua White <joshua.white@monash.edu>
0 siblings, 1 reply; 7+ messages in thread
From: Pavel Stehule @ 2018-12-20 03:34 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>
čt 20. 12. 2018 v 2:41 odesílatel Ron <ronljohnsonjr@gmail.com> napsal:
> On 12/19/18 7:27 PM, Michael Paquier wrote:
> [snip]
> > Each backend stores its own copy of the relation cache, so if you have
> > idle connections which have been used for other work in the past then
> > the memory of those caches is still around. Idle connections also have
> > a CPU cost in Postgres when building snapshots for example, and their
> > entries need to be scanned from a wider array, but usually the relation
> > cache bloat is a wider problem.
>
> So it's best to kill connections that have been idle for a while?
>
sure - one hour idle connection is too old.
>
> --
> Angular momentum makes the world go 'round.
>
>
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Does idle sessions will consume more cpu and ram? If yes,how to control them
2018-12-18 03:45 Does idle sessions will consume more cpu and ram? If yes,how to control them Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-12-20 00:32 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Joshua White <joshua.white@monash.edu>
2018-12-20 01:27 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Michael Paquier <michael@paquier.xyz>
2018-12-20 01:41 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Ron <ronljohnsonjr@gmail.com>
2018-12-20 03:34 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Pavel Stehule <pavel.stehule@gmail.com>
@ 2018-12-20 04:01 ` Joshua White <joshua.white@monash.edu>
2018-12-20 04:45 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 7+ messages in thread
From: Joshua White @ 2018-12-20 04:01 UTC (permalink / raw)
To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: Ron <ronljohnsonjr@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>
On Thu, 20 Dec 2018 at 14:35, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> čt 20. 12. 2018 v 2:41 odesílatel Ron <ronljohnsonjr@gmail.com> napsal:
>
>> On 12/19/18 7:27 PM, Michael Paquier wrote:
>> [snip]
>> > Each backend stores its own copy of the relation cache, so if you have
>> > idle connections which have been used for other work in the past then
>> > the memory of those caches is still around. Idle connections also have
>> > a CPU cost in Postgres when building snapshots for example, and their
>> > entries need to be scanned from a wider array, but usually the relation
>> > cache bloat is a wider problem.
>>
>> So it's best to kill connections that have been idle for a while?
>>
>
> sure - one hour idle connection is too old.
>
I'd also assess closing the connection from the client end once its task is
done - that would reduce the number of idle connections in the first place.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Does idle sessions will consume more cpu and ram? If yes,how to control them
2018-12-18 03:45 Does idle sessions will consume more cpu and ram? If yes,how to control them Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-12-20 00:32 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Joshua White <joshua.white@monash.edu>
2018-12-20 01:27 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Michael Paquier <michael@paquier.xyz>
2018-12-20 01:41 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Ron <ronljohnsonjr@gmail.com>
2018-12-20 03:34 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Pavel Stehule <pavel.stehule@gmail.com>
2018-12-20 04:01 ` Re: Does idle sessions will consume more cpu and ram? If yes,how to control them Joshua White <joshua.white@monash.edu>
@ 2018-12-20 04:45 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 7+ messages in thread
From: Tom Lane @ 2018-12-20 04:45 UTC (permalink / raw)
To: Joshua White <joshua.white@monash.edu>; +Cc: Pavel Stehule <pavel.stehule@gmail.com>; Ron <ronljohnsonjr@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>
Joshua White <joshua.white@monash.edu> writes:
> On Thu, 20 Dec 2018 at 14:35, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>> čt 20. 12. 2018 v 2:41 odesílatel Ron <ronljohnsonjr@gmail.com> napsal:
>>> So it's best to kill connections that have been idle for a while?
>> sure - one hour idle connection is too old.
> I'd also assess closing the connection from the client end once its task is
> done - that would reduce the number of idle connections in the first place.
IMO, "has it been idle a long time" is the wrong question. The right
question is "how likely is it to start doing something useful soon".
Certainly, leaving sessions sit doing nothing for a long time isn't
helpful. They consume RAM, they have to be accounted for by other
sessions, and if you're doing any DDL, they consume CPU time
maintaining their own caches in response to catalog changes. But it's
also true that starting a new session has a lot of overhead --- so you
don't want to kill a session that was just about to start doing some
useful work.
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2018-12-20 04:45 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-12-18 03:45 Does idle sessions will consume more cpu and ram? If yes,how to control them Raghavendra Rao J S V <raghavendrajsv@gmail.com>
2018-12-20 00:32 ` Joshua White <joshua.white@monash.edu>
2018-12-20 01:27 ` Michael Paquier <michael@paquier.xyz>
2018-12-20 01:41 ` Ron <ronljohnsonjr@gmail.com>
2018-12-20 03:34 ` Pavel Stehule <pavel.stehule@gmail.com>
2018-12-20 04:01 ` Joshua White <joshua.white@monash.edu>
2018-12-20 04:45 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox