pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Slow Postgresql server
13+ messages / 7 participants
[nested] [flat]

* Slow Postgresql server
@ 2007-04-11 22:02 Jason Lustig <lustig@brandeis.edu>
  2007-04-12 04:34 ` Re: Slow Postgresql server Dennis Bjorklund <db@zigo.dhs.org>
  2007-04-12 05:33 ` Re: Slow Postgresql server Jeff Frost <jeff@frostconsultingllc.com>
  2007-04-12 13:26 ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
  0 siblings, 3 replies; 13+ messages in thread

From: Jason Lustig @ 2007-04-11 22:02 UTC (permalink / raw)
  To: pgsql-performance

Hello all,

My website has been having issues with our new Linux/PostgreSQL  
server being somewhat slow. I have done tests using Apache Benchmark  
and for pages that do not connect to Postgres, the speeds are much  
faster (334 requests/second v. 1-2 requests/second), so it seems that  
Postgres is what's causing the problem and not Apache. I did some  
reserach, and it seems that the bottleneck is in fact the hard  
drives! Here's an excerpt from vmstat:

procs -----------memory---------- ---swap-- -----io---- --system--  
-----cpu------
r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us  
sy id wa st
1  1    140  24780 166636 575144    0    0     0  3900 1462  3299  1   
4 49 48  0
0  1    140  24780 166636 575144    0    0     0  3828 1455  3391  0   
4 48 48  0
1  1    140  24780 166636 575144    0    0     0  2440  960  2033  0   
3 48 48  0
0  1    140  24780 166636 575144    0    0     0  2552 1001  2131  0   
2 50 49  0
0  1    140  24780 166636 575144    0    0     0  3188 1233  2755  0   
3 49 48  0
0  1    140  24780 166636 575144    0    0     0  2048  868  1812  0   
2 49 49  0
0  1    140  24780 166636 575144    0    0     0  2720 1094  2386  0   
3 49 49  0

As you can see, almost 50% of the CPU is waiting on I/O. This doesn't  
seem like it should be happening, however, since we are using a RAID  
1 setup (160+160). We have 1GB ram, and have upped shared_buffers to  
13000 and work_mem to 8096. What would cause the computer to only use  
such a small percentage of the CPU, with more than half of it waiting  
on I/O requests?

Thanks a lot
Jason




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
@ 2007-04-12 04:34 ` Dennis Bjorklund <db@zigo.dhs.org>
  2 siblings, 0 replies; 13+ messages in thread

From: Dennis Bjorklund @ 2007-04-12 04:34 UTC (permalink / raw)
  To: Jason Lustig <lustig@brandeis.edu>; +Cc: pgsql-performance

Jason Lustig skrev:
> and work_mem to 8096. What would cause the computer to only use such a 
> small percentage of the CPU, with more than half of it waiting on I/O 
> requests?

Do your webpages write things to the database on each connect?

Maybe it do a bunch of writes each individually commited? For every 
commit pg will wait for the data to be written down to the disk platter 
before it move on. So if you do several writes you want to do them in 
one transaction so you only need one commit.

/Dennis



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
@ 2007-04-12 05:33 ` Jeff Frost <jeff@frostconsultingllc.com>
  2007-04-12 15:35   ` Re: Slow Postgresql server Jeff Frost <jeff@frostconsultingllc.com>
  2 siblings, 1 reply; 13+ messages in thread

From: Jeff Frost @ 2007-04-12 05:33 UTC (permalink / raw)
  To: Jason Lustig <lustig@brandeis.edu>; +Cc: pgsql-performance

On Wed, 11 Apr 2007, Jason Lustig wrote:

> Hello all,
>
> My website has been having issues with our new Linux/PostgreSQL server being 
> somewhat slow. I have done tests using Apache Benchmark and for pages that do 
> not connect to Postgres, the speeds are much faster (334 requests/second v. 
> 1-2 requests/second), so it seems that Postgres is what's causing the problem 
> and not Apache. I did some reserach, and it seems that the bottleneck is in 
> fact the hard drives! Here's an excerpt from vmstat:
>
> procs -----------memory---------- ---swap-- -----io---- --system-- 
> -----cpu------
> r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa 
> st
> 1  1    140  24780 166636 575144    0    0     0  3900 1462  3299  1  4 49 48 
> 0
> 0  1    140  24780 166636 575144    0    0     0  3828 1455  3391  0  4 48 48 
> 0
> 1  1    140  24780 166636 575144    0    0     0  2440  960  2033  0  3 48 48 
> 0
> 0  1    140  24780 166636 575144    0    0     0  2552 1001  2131  0  2 50 49 
> 0
> 0  1    140  24780 166636 575144    0    0     0  3188 1233  2755  0  3 49 48 
> 0
> 0  1    140  24780 166636 575144    0    0     0  2048  868  1812  0  2 49 49 
> 0
> 0  1    140  24780 166636 575144    0    0     0  2720 1094  2386  0  3 49 49 
> 0
>
> As you can see, almost 50% of the CPU is waiting on I/O. This doesn't seem 
> like it should be happening, however, since we are using a RAID 1 setup 
> (160+160). We have 1GB ram, and have upped shared_buffers to 13000 and 
> work_mem to 8096. What would cause the computer to only use such a small 
> percentage of the CPU, with more than half of it waiting on I/O requests?

Well, the simple answer is a slow disk subsystem.  Is it hardware or software 
RAID1?  If hardware, what's the RAID controller?  Based on your vmstat output, 
I'd guess that this query activity is all writes since I see only blocks out. 
Can you identify what the slow queries are?  What version of postgres?  How 
large is the database?  Can you post the non-default values in your 
postgresql.conf?

I'd suggest you test your disk subsystem to see if it's as performant as you 
think with bonnie++.  Here's some output from my RAID1 test server:

Version  1.03       ------Sequential Output------ --Sequential Input- --Random-
                     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
pgtest           4G 47090  92 52348  11 30954   6 41838  65 73396   8 255.9  1
                     ------Sequential Create------ --------Random Create--------
                     -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
               files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                  16   894   2 +++++ +++   854   1   817   2 +++++ +++   969 2

So, that's 52MB/sec block writes and 73MB/sec block reads.  That's typical of 
a RAID1 on 2 semi-fast SATA drives.

If you're doing writes to the DB on every web page, you might consider playing 
with the commit_delay and commit_siblings parameters in the postgresql.conf. 
Also, if you're doing multiple inserts as separate transactions, you should 
consider batching them up in one transaction.

-- 
Jeff Frost, Owner 	<jeff@frostconsultingllc.com>
Frost Consulting, LLC 	http://www.frostconsultingllc.com/
Phone: 650-780-7908	FAX: 650-649-1954



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
  2007-04-12 05:33 ` Re: Slow Postgresql server Jeff Frost <jeff@frostconsultingllc.com>
@ 2007-04-12 15:35   ` Jeff Frost <jeff@frostconsultingllc.com>
  2007-04-12 21:58     ` Re: Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
  0 siblings, 1 reply; 13+ messages in thread

From: Jeff Frost @ 2007-04-12 15:35 UTC (permalink / raw)
  To: Jason Lustig <lustig@brandeis.edu>; +Cc: pgsql-performance

On Thu, 12 Apr 2007, Jason Lustig wrote:

> 0 <-- BM starts here
> 10  0    180 700436  16420  91740    0    0     0   176  278  2923 59 41  0 
> 0  0
> 11  0    180 696736  16420  91740    0    0     0     0  254  2904 57 43  0 
> 0  0
> 12  0    180 691272  16420  91740    0    0     0     0  255  3043 60 39  1 
> 0  0
> 9  0    180 690396  16420  91740    0    0     0     0  254  3078 63 36  2  0 
> 0
>
> Obviously, I've turned off logging now but I'd like to get it running again 
> (without bogging down the server) so that I can profile the system and find 
> out which queries I need to optimize. My logging settings (with unnecessary 
> comments taken out) were:

So what did you get in the logs when you had logging turned on?  If you have 
the statement logging, perhaps it's worth running through pgfouine to generate 
a report.

>
> log_destination = 'syslog'            # Valid values are combinations of
> redirect_stderr = off                   # Enable capturing of stderr into log
> log_min_duration_statement =  0              # -1 is disabled, 0 logs all 
> statements
> silent_mode = on                        # DO NOT USE without syslog or
> log_duration = off
> log_line_prefix = 'user=%u,db=%d'                       # Special values:
> log_statement = 'none'                  # none, ddl, mod, all
>

Perhaps you just want to log slow queries > 100ms?  But since you don't seem 
to know what queries you're running on each web page, I'd suggest you just 
turn on the following and run your benchmark against it, then turn it back 
off:

log_duration = on
log_statement = 'all'

Then go grab pgfouine and run the report against the logs to see what queries 
are chewing up all your time.

> So you know, we're using Postgres 8.2.3. The database currently is pretty 
> small (we're just running a testing database right now with a few megabytes 
> of data). No doubt some of our queries are slow, but I was concerned because 
> no matter how slow the queries were (at most the worst were taking a couple 
> of msecs anyway), I was getting ridiculously slow responses from the server. 
> Outside of logging, our only other non-default postgresql.conf items are:
>
> shared_buffers = 13000                  # min 128kB or max_connections*16kB
> work_mem = 8096                         # min 64kB
>
> In terms of the server itself, I think that it uses software raid. How can I 
> tell? Our hosting company set it up with the server so I guess I could ask 
> them, but is there a program I can run which will tell me the information? I 
> also ran bonnie++ and got this output:
>
> Version  1.03       ------Sequential Output------ --Sequential Input- 
> --Random-
>                   -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- 
> --Seeks--
> Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec 
> %CP
> pgtest 2000M 29277  67 33819  15 15446   4 35144  62 48887   5 152.7   0
>                   ------Sequential Create------ --------Random 
> Create--------
>                   -Create-- --Read--- -Delete-- -Create-- --Read--- 
> -Delete--
>             files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec 
> %CP
>                16 17886  77 +++++ +++ +++++ +++ 23258  99 +++++ +++ +++++ 
> +++
>
> So I'm getting 33MB and 48MB write/read respectively. Is this slow? Is there 
> anything I should be doing to optimize our RAID configuration?
>

It's not fast, but at least it's about the same speed as an average IDE drive 
from this era.  More disks would help, but since you indicate the DB fits in 
RAM with plenty of room to spare, how about you update your 
effective_cache_size to something reasonable.  You can use the output of the 
'free' command and take the cache number and divide by 8 to get a reasonable 
value on linux.  Then turn on logging and run your benchmark.  After that, run 
a pgfouine report against the log and post us the explain analyze from your 
slow queries.

And if Ron is indeed local, it might be worthwhile to contact him.  Someone 
onsite would likely get this taken care of much faster than we can on the 
mailing list.

-- 
Jeff Frost, Owner 	<jeff@frostconsultingllc.com>
Frost Consulting, LLC 	http://www.frostconsultingllc.com/
Phone: 650-780-7908	FAX: 650-649-1954



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
  2007-04-12 05:33 ` Re: Slow Postgresql server Jeff Frost <jeff@frostconsultingllc.com>
  2007-04-12 15:35   ` Re: Slow Postgresql server Jeff Frost <jeff@frostconsultingllc.com>
@ 2007-04-12 21:58     ` Jason Lustig <lustig@brandeis.edu>
  2007-04-12 22:18       ` Re: Slow Postgresql server Guido Neitzer <lists@event-s.net>
  0 siblings, 1 reply; 13+ messages in thread

From: Jason Lustig @ 2007-04-12 21:58 UTC (permalink / raw)
  To: Jeff Frost <jeff@frostconsultingllc.com>; +Cc: pgsql-performance

Hi all,

Wow! That's a lot to respond to. Let me go through some of the  
ideas... First, I just turned on autovacuum, I forgot to do that. I'm  
not seeing a major impact though. Also, I know that it's not optimal  
for a dedicated server. It's not just for postgres, it's also got our  
apache server on it. We're just getting started and didn't want to  
make the major investment right now in getting the most expensive  
server we can get. Within the next year, as our traffic grows, we  
will most likely upgrade, but for now when we're in the beginning  
phases of our project, we're going to work with this server.

In terms of RAID not helping speed-wise (only making an impact in  
data integrity) - I was under the impression that even a mirrored  
disk set improves speed, because read requests can be sent to either  
of the disk controllers. Is this incorrect?

I turned on logging again, only logging queries > 5ms. and it caused  
the same problems. I think it might be an issue within the OS's  
logging facilities, since it's going through stderr.

Some of the queries are definitely making an impact on the speed. We  
are constantly trying to improve performance, and part of that is  
reassessing our indexes and denormalizing data where it would help.  
We're also doing work with memcached to cache the results of some of  
the more expensive operations.

Thanks for all your help guys - it's really fantastic to see the  
community here! I've got a lot of database experience (mostly with ms  
sql and mysql) but this is my first time doing serious work with  
postgres and it's really a great system with great people too.

Jason

On Apr 12, 2007, at 11:35 AM, Jeff Frost wrote:

> On Thu, 12 Apr 2007, Jason Lustig wrote:
>
>> 0 <-- BM starts here
>> 10  0    180 700436  16420  91740    0    0     0   176  278  2923  
>> 59 41  0 0  0
>> 11  0    180 696736  16420  91740    0    0     0     0  254  2904  
>> 57 43  0 0  0
>> 12  0    180 691272  16420  91740    0    0     0     0  255  3043  
>> 60 39  1 0  0
>> 9  0    180 690396  16420  91740    0    0     0     0  254  3078  
>> 63 36  2  0 0
>>
>> Obviously, I've turned off logging now but I'd like to get it  
>> running again (without bogging down the server) so that I can  
>> profile the system and find out which queries I need to optimize.  
>> My logging settings (with unnecessary comments taken out) were:
>
> So what did you get in the logs when you had logging turned on?  If  
> you have the statement logging, perhaps it's worth running through  
> pgfouine to generate a report.
>
>>
>> log_destination = 'syslog'            # Valid values are  
>> combinations of
>> redirect_stderr = off                   # Enable capturing of  
>> stderr into log
>> log_min_duration_statement =  0              # -1 is disabled, 0  
>> logs all statements
>> silent_mode = on                        # DO NOT USE without  
>> syslog or
>> log_duration = off
>> log_line_prefix = 'user=%u,db=%d'                       # Special  
>> values:
>> log_statement = 'none'                  # none, ddl, mod, all
>>
>
> Perhaps you just want to log slow queries > 100ms?  But since you  
> don't seem to know what queries you're running on each web page,  
> I'd suggest you just turn on the following and run your benchmark  
> against it, then turn it back off:
>
> log_duration = on
> log_statement = 'all'
>
> Then go grab pgfouine and run the report against the logs to see  
> what queries are chewing up all your time.
>
>> So you know, we're using Postgres 8.2.3. The database currently is  
>> pretty small (we're just running a testing database right now with  
>> a few megabytes of data). No doubt some of our queries are slow,  
>> but I was concerned because no matter how slow the queries were  
>> (at most the worst were taking a couple of msecs anyway), I was  
>> getting ridiculously slow responses from the server. Outside of  
>> logging, our only other non-default postgresql.conf items are:
>>
>> shared_buffers = 13000                  # min 128kB or  
>> max_connections*16kB
>> work_mem = 8096                         # min 64kB
>>
>> In terms of the server itself, I think that it uses software raid.  
>> How can I tell? Our hosting company set it up with the server so I  
>> guess I could ask them, but is there a program I can run which  
>> will tell me the information? I also ran bonnie++ and got this  
>> output:
>>
>> Version  1.03       ------Sequential Output------ --Sequential  
>> Input- --Random-
>>                   -Per Chr- --Block-- -Rewrite- -Per Chr- -- 
>> Block-- --Seeks--
>> Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec % 
>> CP  /sec %CP
>> pgtest 2000M 29277  67 33819  15 15446   4 35144  62 48887   5  
>> 152.7   0
>>                   ------Sequential Create------ --------Random  
>> Create--------
>>                   -Create-- --Read--- -Delete-- -Create-- -- 
>> Read--- -Delete--
>>             files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec % 
>> CP  /sec %CP
>>                16 17886  77 +++++ +++ +++++ +++ 23258  99 +++++ ++ 
>> + +++++ +++
>>
>> So I'm getting 33MB and 48MB write/read respectively. Is this  
>> slow? Is there anything I should be doing to optimize our RAID  
>> configuration?
>>
>
> It's not fast, but at least it's about the same speed as an average  
> IDE drive from this era.  More disks would help, but since you  
> indicate the DB fits in RAM with plenty of room to spare, how about  
> you update your effective_cache_size to something reasonable.  You  
> can use the output of the 'free' command and take the cache number  
> and divide by 8 to get a reasonable value on linux.  Then turn on  
> logging and run your benchmark.  After that, run a pgfouine report  
> against the log and post us the explain analyze from your slow  
> queries.
>
> And if Ron is indeed local, it might be worthwhile to contact him.   
> Someone onsite would likely get this taken care of much faster than  
> we can on the mailing list.
>
> -- 
> Jeff Frost, Owner 	<jeff@frostconsultingllc.com>
> Frost Consulting, LLC 	http://www.frostconsultingllc.com/
> Phone: 650-780-7908	FAX: 650-649-1954




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
  2007-04-12 05:33 ` Re: Slow Postgresql server Jeff Frost <jeff@frostconsultingllc.com>
  2007-04-12 15:35   ` Re: Slow Postgresql server Jeff Frost <jeff@frostconsultingllc.com>
  2007-04-12 21:58     ` Re: Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
@ 2007-04-12 22:18       ` Guido Neitzer <lists@event-s.net>
  0 siblings, 0 replies; 13+ messages in thread

From: Guido Neitzer @ 2007-04-12 22:18 UTC (permalink / raw)
  To: Jason Lustig <lustig@brandeis.edu>; +Cc: pgsql-performance

On 12.04.2007, at 15:58, Jason Lustig wrote:

> Wow! That's a lot to respond to. Let me go through some of the  
> ideas... First, I just turned on autovacuum, I forgot to do that.  
> I'm not seeing a major impact though. Also, I know that it's not  
> optimal for a dedicated server.

Hmm, why not? Have you recently vacuumed your db manually so it gets  
cleaned up? Even a vacuum full might be useful if the db is really  
bloated.

> It's not just for postgres, it's also got our apache server on it.  
> We're just getting started and didn't want to make the major  
> investment right now in getting the most expensive server we can get

Hmmm, but more RAM would definitely make sense, especially in that  
szenaria. It really sounds like you machine is swapping to dead.

What does the system say about memory usage?

> Some of the queries are definitely making an impact on the speed.  
> We are constantly trying to improve performance, and part of that  
> is reassessing our indexes and denormalizing data where it would  
> help. We're also doing work with memcached to cache the results of  
> some of the more expensive operations.

Hmmm, that kills you even more, as it uses RAM. I really don't think  
at the moment that it has something to do with PG itself, but with  
not enough memory for what you want to achieve.

What perhaps helps might be connection pooling, so that not so many  
processes are created for the requests. It depends on your "middle- 
ware" what you can do about that. pg_pool might be an option.

cug





^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
@ 2007-04-12 13:26 ` Ron <rjpeace@earthlink.net>
  2007-04-12 14:08   ` Re: Slow Postgresql server Guido Neitzer <lists@event-s.net>
  2 siblings, 1 reply; 13+ messages in thread

From: Ron @ 2007-04-12 13:26 UTC (permalink / raw)
  To: Jason Lustig <lustig@brandeis.edu>; +Cc: pgsql-performance

1= RAID 1improves data =intregrity=, not IO performance.
Your HD IO performance is essentially that of 1 160GB HD of whatever 
performance one of those HDs have.
(what kind of HDs are they anyway?  For instance 7200rpm 160GB HDs 
are not particularly "high performance")
BEST case is streaming IO involving no seeks => ~50 MBps.
You can't get even that as the back end of a website.

2= 1GB of RAM is -small- for a DB server.

You need to buy RAM and HD.

Boost the RAM to 4GB, change pg config parameters appropriately and 
see how much it helps.
Non ECC RAM is currently running ~$60-$75 per GB for 1 or 2 GB sticks
ECC RAM prices will be ~ 1.5x - 2x that, $120 - $150 per GB for 1 or 
2 GB sticks.
(do !not! buy 4GB sticks unless you have a large budget.  Their price 
pr GB is still too high)

If adding RAM helps as much as I suspect it will, find out how big 
the "hot" section of your DB is and see if you can buy enough RAM to 
make it RAM resident.
If you can do this, it will result in the lowest term DB maintenance.

If you can't do that for whatever reason, the next step is to improve 
your HD subsystem.
Cheap RAID cards with enough BB cache to allow writes to be coalesced 
into larger streams (reducing seeks) will help, but you fundamentally 
you will need more HDs.

RAID 5 is an reasonable option for most website DBs workloads.
To hit the 300MBps speeds attainable by the cheap RAID cards, you are 
going to at least 7 HDs (6 HDs * 50MBps ASTR = 300MBps ASTR + the 
equivalent of 1 HD gets used for the "R" in RAID).  A minimum of 8 
HDs are need for this performance if you want to use RAID 6.
Most tower case (not mini-tower, tower) cases can hold this internally.
Price per MBps of HD is all over the map.  The simplest (but not 
necessarily best) option is to buy more of the 160GB HDs you already have.
Optimizing the money spent when buying HDs for a RAID set is a bit 
more complicated than doing so for RAM.  Lot's of context dependent 
things affect the final decision.

I see you are mailing from Brandeis.  I'm local.  Drop me some 
private email at the address I'm posting from if you want and I'll 
send you further contact info so we can talk in more detail.

Cheers,
Ron Peacetree


At 06:02 PM 4/11/2007, Jason Lustig wrote:
>Hello all,
>
>My website has been having issues with our new Linux/PostgreSQL
>server being somewhat slow. I have done tests using Apache Benchmark
>and for pages that do not connect to Postgres, the speeds are much
>faster (334 requests/second v. 1-2 requests/second), so it seems that
>Postgres is what's causing the problem and not Apache. I did some
>reserach, and it seems that the bottleneck is in fact the hard
>drives! Here's an excerpt from vmstat:
>
>procs -----------memory---------- ---swap-- -----io---- --system--
>-----cpu------
>r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us
>sy id wa st
>1  1    140  24780 166636 575144    0    0     0  3900 1462  3299  1
>4 49 48  0
>0  1    140  24780 166636 575144    0    0     0  3828 1455  3391  0
>4 48 48  0
>1  1    140  24780 166636 575144    0    0     0  2440  960  2033  0
>3 48 48  0
>0  1    140  24780 166636 575144    0    0     0  2552 1001  2131  0
>2 50 49  0
>0  1    140  24780 166636 575144    0    0     0  3188 1233  2755  0
>3 49 48  0
>0  1    140  24780 166636 575144    0    0     0  2048  868  1812  0
>2 49 49  0
>0  1    140  24780 166636 575144    0    0     0  2720 1094  2386  0
>3 49 49  0
>
>As you can see, almost 50% of the CPU is waiting on I/O. This doesn't
>seem like it should be happening, however, since we are using a RAID
>1 setup (160+160). We have 1GB ram, and have upped shared_buffers to
>13000 and work_mem to 8096. What would cause the computer to only use
>such a small percentage of the CPU, with more than half of it waiting
>on I/O requests?
>
>Thanks a lot
>Jason
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
  2007-04-12 13:26 ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
@ 2007-04-12 14:08   ` Guido Neitzer <lists@event-s.net>
  2007-04-12 14:59     ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
  0 siblings, 1 reply; 13+ messages in thread

From: Guido Neitzer @ 2007-04-12 14:08 UTC (permalink / raw)
  To: pgsql-performance

On 12.04.2007, at 07:26, Ron wrote:

> You need to buy RAM and HD.

Before he does that, wouldn't it be more useful, to find out WHY he  
has so much IO?

Have I missed that or has nobody suggested finding the slow queries  
(when you have much IO on them, they might be slow at least with a  
high shared memory setting).

So, my first idea is, to turn on query logging for queries longer  
than a xy milliseconds, "explain analyse" these queries and see  
wether there are a lot of seq scans involved, which would explain the  
high IO.

Just an idea, perhaps I missed that step in that discussion  
somewhere ...

But yes, it might also be, that the server is swapping, that's  
another thing to find out.

cug



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
  2007-04-12 13:26 ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
  2007-04-12 14:08   ` Re: Slow Postgresql server Guido Neitzer <lists@event-s.net>
@ 2007-04-12 14:59     ` Ron <rjpeace@earthlink.net>
  2007-04-12 15:19       ` Re: Slow Postgresql server Guido Neitzer <lists@event-s.net>
  0 siblings, 1 reply; 13+ messages in thread

From: Ron @ 2007-04-12 14:59 UTC (permalink / raw)
  To: Guido Neitzer <lists@event-s.net>; +Cc: pgsql-performance

At 10:08 AM 4/12/2007, Guido Neitzer wrote:
>On 12.04.2007, at 07:26, Ron wrote:
>
>>You need to buy RAM and HD.
>
>Before he does that, wouldn't it be more useful, to find out WHY he
>has so much IO?

1= Unless I missed something, the OP described pg being used as a 
backend DB for a webserver.

I know the typical IO demands of that scenario better than I sometimes want to.
:-(


2= 1GB of RAM + effectively 1 160GB HD = p*ss poor DB IO support.
~ 1/2 that RAM is going to be used for OS stuff, leaving only ~512MB 
of RAM to be used supporting pg.
That RAID 1 set is effectively 1 HD head that all IO requests are 
going to contend for.
Even if the HD in question is a 15Krpm screamer, that level of HW 
contention has very adverse implications.


Completely agree that at some point the queries need to be examined 
(ditto the table schema, etc), but this system is starting off in a 
Bad Place for its stated purpose IME.
Some minimum stuff is obvious even w/o spending time looking at 
anything beyond the HW config.

Cheers,
Ron Peacetree


>Have I missed that or has nobody suggested finding the slow queries
>(when you have much IO on them, they might be slow at least with a
>high shared memory setting).
>
>So, my first idea is, to turn on query logging for queries longer
>than a xy milliseconds, "explain analyse" these queries and see
>wether there are a lot of seq scans involved, which would explain the
>high IO.
>
>Just an idea, perhaps I missed that step in that discussion
>somewhere ...
>
>But yes, it might also be, that the server is swapping, that's
>another thing to find out.
>
>cug
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq




^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
  2007-04-12 13:26 ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
  2007-04-12 14:08   ` Re: Slow Postgresql server Guido Neitzer <lists@event-s.net>
  2007-04-12 14:59     ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
@ 2007-04-12 15:19       ` Guido Neitzer <lists@event-s.net>
  2007-04-12 16:56         ` Re: Slow Postgresql server Scott Marlowe <smarlowe@g2switchworks.com>
  0 siblings, 1 reply; 13+ messages in thread

From: Guido Neitzer @ 2007-04-12 15:19 UTC (permalink / raw)
  To: Ron <rjpeace@earthlink.net>; pgsql-performance

On 12.04.2007, at 08:59, Ron wrote:

> 1= Unless I missed something, the OP described pg being used as a  
> backend DB for a webserver.

Yep.

> I know the typical IO demands of that scenario better than I  
> sometimes want to.
> :-(

Yep. Same here. ;-)

> 2= 1GB of RAM + effectively 1 160GB HD = p*ss poor DB IO support.

Absolutely right. Depending a little bit on the DB and WebSite layout  
and on the actual requirements, but yes - it's not really a kick-ass  
machine ...

> Completely agree that at some point the queries need to be examined  
> (ditto the table schema, etc), but this system is starting off in a  
> Bad Place for its stated purpose IME.
> Some minimum stuff is obvious even w/o spending time looking at  
> anything beyond the HW config.

Depends. As I said - if the whole DB fits into the remaining space,  
and a lot of website backend DBs do, it might just work out. But this  
seems not to be the case - either the site is chewing on seq scans  
all the time which will cause I/O or it is bound by the lack of  
memory and swaps the whole time ... He has to find out.

cug



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
  2007-04-12 13:26 ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
  2007-04-12 14:08   ` Re: Slow Postgresql server Guido Neitzer <lists@event-s.net>
  2007-04-12 14:59     ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
  2007-04-12 15:19       ` Re: Slow Postgresql server Guido Neitzer <lists@event-s.net>
@ 2007-04-12 16:56         ` Scott Marlowe <smarlowe@g2switchworks.com>
  2007-04-12 17:03           ` Re: Slow Postgresql server Jeff Frost <jeff@frostconsultingllc.com>
  0 siblings, 1 reply; 13+ messages in thread

From: Scott Marlowe @ 2007-04-12 16:56 UTC (permalink / raw)
  To: Guido Neitzer <lists@event-s.net>; +Cc: Ron <rjpeace@earthlink.net>; pgsql-performance

On Thu, 2007-04-12 at 10:19, Guido Neitzer wrote:
> On 12.04.2007, at 08:59, Ron wrote:

> 
> Depends. As I said - if the whole DB fits into the remaining space,  
> and a lot of website backend DBs do, it might just work out. But this  
> seems not to be the case - either the site is chewing on seq scans  
> all the time which will cause I/O or it is bound by the lack of  
> memory and swaps the whole time ... He has to find out.

It could also be something as simple as a very bloated data store.

I'd ask the user what vacuum verbose says at the end



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
  2007-04-12 13:26 ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
  2007-04-12 14:08   ` Re: Slow Postgresql server Guido Neitzer <lists@event-s.net>
  2007-04-12 14:59     ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
  2007-04-12 15:19       ` Re: Slow Postgresql server Guido Neitzer <lists@event-s.net>
  2007-04-12 16:56         ` Re: Slow Postgresql server Scott Marlowe <smarlowe@g2switchworks.com>
@ 2007-04-12 17:03           ` Jeff Frost <jeff@frostconsultingllc.com>
  2007-04-12 19:10             ` Re: Slow Postgresql server Carlos Moreno <moreno_pg@mochima.com>
  0 siblings, 1 reply; 13+ messages in thread

From: Jeff Frost @ 2007-04-12 17:03 UTC (permalink / raw)
  To: Jason Lustig <lustig@brandeis.edu>; Scott Marlowe <smarlowe@g2switchworks.com>; +Cc: Guido Neitzer <lists@event-s.net>; Ron <rjpeace@earthlink.net>; pgsql-performance

On Thu, 12 Apr 2007, Scott Marlowe wrote:

> On Thu, 2007-04-12 at 10:19, Guido Neitzer wrote:
>> On 12.04.2007, at 08:59, Ron wrote:
>
>>
>> Depends. As I said - if the whole DB fits into the remaining space,
>> and a lot of website backend DBs do, it might just work out. But this
>> seems not to be the case - either the site is chewing on seq scans
>> all the time which will cause I/O or it is bound by the lack of
>> memory and swaps the whole time ... He has to find out.
>
> It could also be something as simple as a very bloated data store.
>
> I'd ask the user what vacuum verbose says at the end

You know, I should answer emails at night...we didn't ask when the last time 
the data was vacuumed or analyzed and I believe he indicated that the only 
non-default values were memory related, so no autovacuum running.

Jason,

Before you go any further, run 'vacuum analyze;' on your DB if you're not 
doing this with regularity and strongly consider enabling autovacuum.

-- 
Jeff Frost, Owner 	<jeff@frostconsultingllc.com>
Frost Consulting, LLC 	http://www.frostconsultingllc.com/
Phone: 650-780-7908	FAX: 650-649-1954



^ permalink  raw  reply  [nested|flat] 13+ messages in thread

* Re: Slow Postgresql server
  2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
  2007-04-12 13:26 ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
  2007-04-12 14:08   ` Re: Slow Postgresql server Guido Neitzer <lists@event-s.net>
  2007-04-12 14:59     ` Re: Slow Postgresql server Ron <rjpeace@earthlink.net>
  2007-04-12 15:19       ` Re: Slow Postgresql server Guido Neitzer <lists@event-s.net>
  2007-04-12 16:56         ` Re: Slow Postgresql server Scott Marlowe <smarlowe@g2switchworks.com>
  2007-04-12 17:03           ` Re: Slow Postgresql server Jeff Frost <jeff@frostconsultingllc.com>
@ 2007-04-12 19:10             ` Carlos Moreno <moreno_pg@mochima.com>
  0 siblings, 0 replies; 13+ messages in thread

From: Carlos Moreno @ 2007-04-12 19:10 UTC (permalink / raw)
  To: Jeff Frost <jeff@frostconsultingllc.com>; +Cc: pgsql-performance

Jeff Frost wrote:
>
> You know, I should answer emails at night...

Indeed you shouldN'T   ;-)

Carlos
--




^ permalink  raw  reply  [nested|flat] 13+ messages in thread


end of thread, other threads:[~2007-04-12 22:18 UTC | newest]

Thread overview: 13+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-04-11 22:02 Slow Postgresql server Jason Lustig <lustig@brandeis.edu>
2007-04-12 04:34 ` Dennis Bjorklund <db@zigo.dhs.org>
2007-04-12 05:33 ` Jeff Frost <jeff@frostconsultingllc.com>
2007-04-12 15:35   ` Jeff Frost <jeff@frostconsultingllc.com>
2007-04-12 21:58     ` Jason Lustig <lustig@brandeis.edu>
2007-04-12 22:18       ` Guido Neitzer <lists@event-s.net>
2007-04-12 13:26 ` Ron <rjpeace@earthlink.net>
2007-04-12 14:08   ` Guido Neitzer <lists@event-s.net>
2007-04-12 14:59     ` Ron <rjpeace@earthlink.net>
2007-04-12 15:19       ` Guido Neitzer <lists@event-s.net>
2007-04-12 16:56         ` Scott Marlowe <smarlowe@g2switchworks.com>
2007-04-12 17:03           ` Jeff Frost <jeff@frostconsultingllc.com>
2007-04-12 19:10             ` Carlos Moreno <moreno_pg@mochima.com>

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