pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aaron Turner <synfinatic@gmail.com>
To: pgsql-performance <pgsql-performance@postgresql.org>
Subject: Re: TCP network cost
Date: Tue, 17 Feb 2009 10:13:40 -0800
Message-ID: <1ca1c1410902171013q478f2620n13fcd68cb8b3d911@mail.gmail.com> (raw)
In-Reply-To: <20090217070403.GB2486@cooker>
References: <20090217070403.GB2486@cooker>

On Mon, Feb 16, 2009 at 11:04 PM, Ross J. Reedstrom <reedstrm@rice.edu> wrote:
> Recently I've been working on improving the performance of a system that
> delivers files stored in postgresql as bytea data. I was surprised at
> just how much a penalty I find moving from a domain socket connection to
> a TCP connection, even localhost. For one particular 40MB file (nothing
> outragous) I see ~ 2.5 sec. to download w/ the domain socket, but ~ 45 sec
> for a TCP connection (either localhost, name of localhost, or from
> another machine 5 hops away (on campus - gigabit LAN) Similar numbers
> for 8.2.3 or 8.3.6 (on Linux/Debian etch + backports)
>
> So, why the 20 fold penalty for using TCP? Any clues on how to trace
> what's up in the network IO stack?

TCP has additional overhead as well as going through the IP stack
which for non-tuned Linux kernels is pretty limiting.

long story short, there are things in /proc you can use to increase
buffers and window sizes which will help with large TCP streams (like
a 40MB file for example).  There's a lot of documentation on the net
for how to tune the Linux IP stack so I won't repeat it here.

Now, having your DB box 5 hops away is going to add a lot of latency
and any packet loss is going to kill TCP throughput- especially if you
increase window sizes.  I'd recommend something like "mtr" to map the
network traffic (make sure you run it both ways in case you have an
asymmetric routing situation) for a long period of time to look for
hiccups.

-- 
Aaron Turner
http://synfin.net/
http://tcpreplay.synfin.net/ - Pcap editing and replay tools for Unix & Windows
Those who would give up essential Liberty, to purchase a little
temporary Safety,
deserve neither Liberty nor Safety.
    -- Benjamin Franklin



view thread (23+ messages)  latest in thread

Message-ID: <1ca1c1410902171013q478f2620n13fcd68cb8b3d911@mail.gmail.com>
Permalink:  ../1ca1c1410902171013q478f2620n13fcd68cb8b3d911@mail.gmail.com/
Also on:    postgresql.org/message-id/1ca1c1410902171013q478f2620n13fcd68cb8b3d911@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: synfinatic@gmail.com
  Subject: Re: TCP network cost
  In-Reply-To: <1ca1c1410902171013q478f2620n13fcd68cb8b3d911@mail.gmail.com>
  References: <20090217070403.GB2486@cooker> <1ca1c1410902171013q478f2620n13fcd68cb8b3d911@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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