Re: postgresql + apache under heavy load

From: Alex Madon <alex(dot)madon(at)bestlinuxjobs(dot)com>
To: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: postgresql + apache under heavy load
Date: 2004-01-21 20:17:59
Message-ID: 400EDE77.4090804@bestlinuxjobs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello Scott,
Thank you for your reply.

>
>I think you're confusing what I meant. Caching is good. Swapping is
bad.
>Having a large amount of cache is a good thing. It means the OS is
>caching all your data in memory for faster access.
>
OK; Sorry about my approximative language. I was meaning, caching to
disk... so better said as you point out is swapping.
So my system is filling the RAM (OK to me) and then begins to fill all
the Swap.
When the swap is used at near 100%, the system becomes extremely
difficult to control (not actually crashing, but accessing disk very
noisily).

>
>OK, there's a problem, you're getting failed requests at -c 10, which
>means you likely have postgresql configured in the wrong
>direction. configure postgresql to use more memory (sort_mem can be set
>to about 8 megs without a lot of issues on most boxes, going higher may
>use up all your memory in certain situations (high concurrency)).
>
Thank you!
I setting sort_mem to 8 Mb and max_connections = 32, I have zero failed
with a c=20 and 1 failed with a c=30!
Decreasing max_connections to 8 gave me a lot of failed as before.

>
>No, you should NEVER have to reboot a unix box. period. filled cache,
>again, is a GOOD THING. not bad.
>
sorry, I was meaning swapping.

>>button)... could be interesting to wait to see if the systems recovers
>>after a while
>
>
>Yes, please do. Also, show us a save of top while under load.

Well, increasing the sort_mem and max_connections was very good to have
less failed, but this does not solve the memory limitation.
Perhaps that comes from my superficial understanding of concurrency.

Does anybody have a simple formula to know how much memory a ab
benchmark will need in this case (assuming one knows the memory needed
by one apache process (A) and the memory used by one postgres process (P)?

I would say, issuing a ab -n N -c C (asuming there is no shared library
between apache and postgres)
memory needed= CxA + CxP
(independent of N?)

Just another pedestrian question: what usually happens to a linux box
when swap is exhausted?
Is the parent process killed? Could this crash the whole machine?

My conclusion up to now, is that this box does not stand more than 40
concurrent connections.
To stand more concurrent connections, I'd need to increase the RAM or
redesign my software, e.g. using a PHP cache, static pages being served
much faster (almost by a factor 100...)
Thanks
Alex

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2004-01-21 20:27:49 Re: postgresql + apache under heavy load
Previous Message Robert Treat 2004-01-21 20:16:48 Re: postgresql + apache under heavy load