Re: Sending several commands simultaneously to PostgreSQL 8.4

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Sending several commands simultaneously to PostgreSQL 8.4
Date: 2013-01-24 02:26:16
Message-ID: CAMkU=1zE=id9EUmwZkHwkSxevRgxD7VPAow5OWv5+tJ3xB4fqg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday, January 21, 2013, Alexander Farber wrote:

> Hello,
>
> I run a card game written in Perl on
> a CentOS 6.3 / 64 bit + PostgreSQL 8.4.13
> where quite a lot player statistics are written
> to the d/b (score, game results, moves, etc.)
>
> Here a player profile: http://preferans.de/DE11198
>
> The machine has a quad intel + 32 GB RAM.
>
> In poostgresql.conf I set:
>
> max_connections = 100
> shared_buffers = 4096MB
> work_mem = 32MB
> log_min_duration_statement = 10000
>
> I also use pgbouncer (for PHP scripts),
> but my Perl game daemon talks
> directly to /tmp/.s.PGSQL.5432
>

Why not have Perl go through pgbouncer as well?

>
> My game daemon runs in a non-forking loop
> and poll()s TCP sockets to the player machines..
>
> Players complain about my server
> freezing for few seconds sometimes
> and I can see it myself in the game logs -
> when data is sometimes written to d/b
> (and postmaster processes take 90% CPU).
>

Any idea what causes that? Your code only seems to do anything with the
database at the time that someone logs out. Does everyone log out at the
same time?

>
> So my question is:
>
> do I have to program a separate daemon -
> which would be polled via a Unix domain
> socket by my main game daemon and
> which would handle sending SQL commands
> (typically insert's and select's)?
>

One alternative possibility would be to use synchronous_commit=off. This
opens up the possibility that transactions would be lost in the case of a
crash. But you change your code to send off updates and not wait for a
response, as you seem to be proposing, then you are also introducing that
possibility, just implicitly.

Cheers,

Jeff

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shridhar Daithankar 2013-01-24 03:31:42 Re: DB alias ?
Previous Message MarkB 2013-01-24 00:41:28 Postgresql error