Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 10:43 AM
Matthew Lunnon
 
Posts: n/a
Default Limited performance on multi core server

Hi,

I have a 4 * dual core 64bit AMD OPTERON server with 16G of RAM, running
postgres 7.4.3. This has been recompiled on the server for 64 stored
procedure parameters, (I assume this makes postgres 64 bit but are not
sure). When the server gets under load from database connections
executing reads, lets say 20 - 40 concurrent reads, the CPU's seem to
limit at about 30-35% usage with no iowait reported. If I run a simple
select at this time it takes 5 seconds, the same query runs in 300
millis when the server is not under load so it seems that the database
is not performing well even though there is plenty of spare CPU. There
does not appear to be large amounts of disk IO and my database is about
5.5G so this should fit comfortably in RAM.

changes to postgresql.sql:

max_connections = 500
shared_buffers = 96000
sort_mem = 10240
effective_cache_size = 1000000

Does anyone have any ideas what my bottle neck might be and what I can
do about it?

Thanks for any help.

Matthew.

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 10:43 AM
Claus Guttesen
 
Posts: n/a
Default Re: Limited performance on multi core server

> I have a 4 * dual core 64bit AMD OPTERON server with 16G of RAM, running
> postgres 7.4.3. This has been recompiled on the server for 64 stored
> procedure parameters, (I assume this makes postgres 64 bit but are not
> sure). When the server gets under load from database connections
> executing reads, lets say 20 - 40 concurrent reads, the CPU's seem to
> limit at about 30-35% usage with no iowait reported. If I run a simple
> select at this time it takes 5 seconds, the same query runs in 300
> millis when the server is not under load so it seems that the database
> is not performing well even though there is plenty of spare CPU. There
> does not appear to be large amounts of disk IO and my database is about
> 5.5G so this should fit comfortably in RAM.
>
> changes to postgresql.sql:
>
> max_connections = 500
> shared_buffers = 96000
> sort_mem = 10240
> effective_cache_size = 1000000
>
> Does anyone have any ideas what my bottle neck might be and what I can
> do about it?


You might want to lower shared_buffers to a lower value. Mine is set
at 32768. Is your db performing complex sort? Remember that this value
is per connection. Maby 1024. effective_cache_size should also be
lowered to something like 32768. As far as I understand shared_buffers
and effective_cache_size have to be altered "in reverse", ie. when
lowering one the other can be raised.

HTH.

--
regards
Claus

When lenity and cruelty play for a kingdom,
the gentlest gamester is the soonest winner.

Shakespeare

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 10:43 AM
Claus Guttesen
 
Posts: n/a
Default Re: Limited performance on multi core server

> > Does anyone have any ideas what my bottle neck might be and what I can do
> > about it?

>
> Your bottleneck is that you are using a very old version of PostgreSQL. Try
> 8.2 or (if you can) the 8.3 beta series -- it scales a _lot_ better in this
> kind of situation.


You won't know until you've seen what queries are performed. Changing
db-parameters is a short-term solution, upgrading to a newer version
does require some planning.

--
regards
Claus

When lenity and cruelty play for a kingdom,
the gentlest gamester is the soonest winner.

Shakespeare

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-19-2008, 10:43 AM
Sven Geisler
 
Posts: n/a
Default Re: Limited performance on multi core server

Hi Matthew,

I know exactly what you experience.
We had a 4-way DC Opteron and Pg 7.4 too.
You should monitor context switches.


First suggest upgrade to 8.2.5 because the scale up is much better with 8.2.

You need to limit the number of concurrent queries to less than 8 (8
cores) if you need to stay with Pg 7.4.

The memory setting is looking good to me. I would increase sort_mem and
effective_cache_size, but this would solve your problem.

Best regards
Sven.



Matthew Lunnon schrieb:
> Hi,
>
> I have a 4 * dual core 64bit AMD OPTERON server with 16G of RAM, running
> postgres 7.4.3. This has been recompiled on the server for 64 stored
> procedure parameters, (I assume this makes postgres 64 bit but are not
> sure). When the server gets under load from database connections
> executing reads, lets say 20 - 40 concurrent reads, the CPU's seem to
> limit at about 30-35% usage with no iowait reported. If I run a simple
> select at this time it takes 5 seconds, the same query runs in 300
> millis when the server is not under load so it seems that the database
> is not performing well even though there is plenty of spare CPU. There
> does not appear to be large amounts of disk IO and my database is about
> 5.5G so this should fit comfortably in RAM.
>
> changes to postgresql.sql:
>
> max_connections = 500
> shared_buffers = 96000
> sort_mem = 10240
> effective_cache_size = 1000000
>
> Does anyone have any ideas what my bottle neck might be and what I can
> do about it?
>
> Thanks for any help.
>
> Matthew.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend


--
Sven Geisler <sgeisler@aeccom.com> Tel +49.30.921017.81 Fax .50
Senior Developer, AEC/communications GmbH & Co. KG Berlin, Germany

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-19-2008, 10:43 AM
Matthew Lunnon
 
Posts: n/a
Default Re: Limited performance on multi core server

Limiting the queries was our initial thought but we then hit a problem
with connection pooling which didn't implement a fifo algorithm. Looks
like I'll have to look deeper into the connection pooling.

So you think the problem might be context switching on the server, I'll
take a closer look at the this

Thanks

Matthew

Sven Geisler wrote:
> Hi Matthew,
>
> I know exactly what you experience.
> We had a 4-way DC Opteron and Pg 7.4 too.
> You should monitor context switches.
>
>
> First suggest upgrade to 8.2.5 because the scale up is much better with 8.2.
>
> You need to limit the number of concurrent queries to less than 8 (8
> cores) if you need to stay with Pg 7.4.
>
> The memory setting is looking good to me. I would increase sort_mem and
> effective_cache_size, but this would solve your problem.
>
> Best regards
> Sven.
>
>
>
> Matthew Lunnon schrieb:
>
>> Hi,
>>
>> I have a 4 * dual core 64bit AMD OPTERON server with 16G of RAM, running
>> postgres 7.4.3. This has been recompiled on the server for 64 stored
>> procedure parameters, (I assume this makes postgres 64 bit but are not
>> sure). When the server gets under load from database connections
>> executing reads, lets say 20 - 40 concurrent reads, the CPU's seem to
>> limit at about 30-35% usage with no iowait reported. If I run a simple
>> select at this time it takes 5 seconds, the same query runs in 300
>> millis when the server is not under load so it seems that the database
>> is not performing well even though there is plenty of spare CPU. There
>> does not appear to be large amounts of disk IO and my database is about
>> 5.5G so this should fit comfortably in RAM.
>>
>> changes to postgresql.sql:
>>
>> max_connections = 500
>> shared_buffers = 96000
>> sort_mem = 10240
>> effective_cache_size = 1000000
>>
>> Does anyone have any ideas what my bottle neck might be and what I can
>> do about it?
>>
>> Thanks for any help.
>>
>> Matthew.
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 6: explain analyze is your friend
>>

>
>


--
Matthew Lunnon
Technical Consultant
RWA Ltd.

mlunnon@rwa-net.co.uk
Tel: +44 (0)29 2081 5056
www.rwa-net.co.uk
--


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-19-2008, 10:43 AM
Matthew Lunnon
 
Posts: n/a
Default Re: Limited performance on multi core server

Ah I was afraid of that. Maybe I'll have to come out of the dark ages.

Matthew

Steinar H. Gunderson wrote:
> On Wed, Dec 12, 2007 at 10:16:43AM +0000, Matthew Lunnon wrote:
>
>> Does anyone have any ideas what my bottle neck might be and what I can do
>> about it?
>>

>
> Your bottleneck is that you are using a very old version of PostgreSQL. Try
> 8.2 or (if you can) the 8.3 beta series -- it scales a _lot_ better in this
> kind of situation.
>
> /* Steinar */
>


--
Matthew Lunnon
Technical Consultant
RWA Ltd.

mlunnon@rwa-net.co.uk
Tel: +44 (0)29 2081 5056
www.rwa-net.co.uk
--


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-19-2008, 10:43 AM
Matthew Lunnon
 
Posts: n/a
Default Re: Limited performance on multi core server

Thanks for the information Claus, Why would reducing the effective
cache size help the processor usage? It seems that there is plenty of
resources on the box although I can see that 10MB of sort space could
mount up if we had 500 connections but at the moment we do not have
anything like that number.

Thanks
Matthew.

Claus Guttesen wrote:
>> I have a 4 * dual core 64bit AMD OPTERON server with 16G of RAM, running
>> postgres 7.4.3. This has been recompiled on the server for 64 stored
>> procedure parameters, (I assume this makes postgres 64 bit but are not
>> sure). When the server gets under load from database connections
>> executing reads, lets say 20 - 40 concurrent reads, the CPU's seem to
>> limit at about 30-35% usage with no iowait reported. If I run a simple
>> select at this time it takes 5 seconds, the same query runs in 300
>> millis when the server is not under load so it seems that the database
>> is not performing well even though there is plenty of spare CPU. There
>> does not appear to be large amounts of disk IO and my database is about
>> 5.5G so this should fit comfortably in RAM.
>>
>> changes to postgresql.sql:
>>
>> max_connections = 500
>> shared_buffers = 96000
>> sort_mem = 10240
>> effective_cache_size = 1000000
>>
>> Does anyone have any ideas what my bottle neck might be and what I can
>> do about it?
>>

>
> You might want to lower shared_buffers to a lower value. Mine is set
> at 32768. Is your db performing complex sort? Remember that this value
> is per connection. Maby 1024. effective_cache_size should also be
> lowered to something like 32768. As far as I understand shared_buffers
> and effective_cache_size have to be altered "in reverse", ie. when
> lowering one the other can be raised.
>
> HTH.
>
>


--
Matthew Lunnon
Technical Consultant
RWA Ltd.

mlunnon@rwa-net.co.uk
Tel: +44 (0)29 2081 5056
www.rwa-net.co.uk
--


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-19-2008, 10:43 AM
Claus Guttesen
 
Posts: n/a
Default Re: Limited performance on multi core server

> Thanks for the information Claus, Why would reducing the effective cache
> size help the processor usage? It seems that there is plenty of resources
> on the box although I can see that 10MB of sort space could mount up if we
> had 500 connections but at the moment we do not have anything like that
> number.


There is a discussion at
http://archives.postgresql.org/pgsql...6/msg00477.php
which can give a clearer picture. But in general rasing values can be
counterproductive.

If you know that you won't need more than 250 connections that would
be a reasonable value. You may wan't to read
http://www.varlena.com/GeneralBits/T...ed_conf_e.html as
well. This has some rules of thumb on the settings for 7.4.x.

--
regards
Claus

When lenity and cruelty play for a kingdom,
the gentlest gamester is the soonest winner.

Shakespeare

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-19-2008, 10:43 AM
Greg Smith
 
Posts: n/a
Default Re: Limited performance on multi core server

On Wed, 12 Dec 2007, Matthew Lunnon wrote:

> I have a 4 * dual core 64bit AMD OPTERON server with 16G of RAM, running
> postgres 7.4.3.
> shared_buffers = 96000


As you've already been told repeatedly 7.4 is a release from long before
optimizations to work well on a multi-core server like this. I'll only
add that because of those problems, larger values of shared_buffers were
sometimes counter-productive with these old versions. You should try
reducing that to the 10,000-50000 range and see if things improve; that's
the general range that was effective with 7.4. Continue to set
effective_cache_size to a large value so that the optimizer knows how much
RAM is really available.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

---------------------------(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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-19-2008, 10:43 AM
Sven Geisler
 
Posts: n/a
Default Re: Limited performance on multi core server

Hi Matthew,

The context switching isn't the issue. This is an indicator which is
useful to identify your problem.

What kind of application do you running? Can you limit the database clients?

We have a web application based on apache running. We have a limit
number of apache processes which are able to connect the database.
We use that to reduce the number of concurrent queries.
The apache does the rest for us - the apache does queue incoming http
request if all workers are busy. The configuration helps us to solve the
performance issue with to much concurrent queries.

I assume that you already checked you application and each sql query is
necessary and tuned as best as you can.

Regards
Sven.

Matthew Lunnon schrieb:
> Limiting the queries was our initial thought but we then hit a problem
> with connection pooling which didn't implement a fifo algorithm. Looks
> like I'll have to look deeper into the connection pooling.
>
> So you think the problem might be context switching on the server, I'll
> take a closer look at the this
>
> Thanks
>
> Matthew
>
> Sven Geisler wrote:
>> Hi Matthew,
>>
>> I know exactly what you experience.
>> We had a 4-way DC Opteron and Pg 7.4 too.
>> You should monitor context switches.
>>
>>
>> First suggest upgrade to 8.2.5 because the scale up is much better with 8.2.
>>
>> You need to limit the number of concurrent queries to less than 8 (8
>> cores) if you need to stay with Pg 7.4.
>>
>> The memory setting is looking good to me. I would increase sort_mem and
>> effective_cache_size, but this would solve your problem.
>>
>> Best regards
>> Sven.
>>
>>
>>
>> Matthew Lunnon schrieb:
>>
>>> Hi,
>>>
>>> I have a 4 * dual core 64bit AMD OPTERON server with 16G of RAM, running
>>> postgres 7.4.3. This has been recompiled on the server for 64 stored
>>> procedure parameters, (I assume this makes postgres 64 bit but are not
>>> sure). When the server gets under load from database connections
>>> executing reads, lets say 20 - 40 concurrent reads, the CPU's seem to
>>> limit at about 30-35% usage with no iowait reported. If I run a simple
>>> select at this time it takes 5 seconds, the same query runs in 300
>>> millis when the server is not under load so it seems that the database
>>> is not performing well even though there is plenty of spare CPU. There
>>> does not appear to be large amounts of disk IO and my database is about
>>> 5.5G so this should fit comfortably in RAM.
>>>
>>> changes to postgresql.sql:
>>>
>>> max_connections = 500
>>> shared_buffers = 96000
>>> sort_mem = 10240
>>> effective_cache_size = 1000000
>>>
>>> Does anyone have any ideas what my bottle neck might be and what I can
>>> do about it?
>>>
>>> Thanks for any help.
>>>
>>> Matthew.
>>>
>>> ---------------------------(end of broadcast)---------------------------
>>> TIP 6: explain analyze is your friend
>>>

>>
>>

>
> --
> Matthew Lunnon
> Technical Consultant
> RWA Ltd.
>
> mlunnon@rwa-net.co.uk
> Tel: +44 (0)29 2081 5056
> www.rwa-net.co.uk
> --
>


--
Sven Geisler <sgeisler@aeccom.com> Tel +49.30.921017.81 Fax .50
Senior Developer, AEC/communications GmbH & Co. KG Berlin, Germany

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:45 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505