Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 504D8B5DC0F for ; Sat, 29 Oct 2011 05:51:24 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 97072-08 for ; Sat, 29 Oct 2011 08:51:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from exprod7og115.obsmtp.com (exprod7og115.obsmtp.com [64.18.2.217]) by mail.postgresql.org (Postfix) with ESMTP id 39406B5DBF0 for ; Sat, 29 Oct 2011 05:51:14 -0300 (ADT) Received: from mail-fx0-f43.google.com ([209.85.161.43]) (using TLSv1) by exprod7ob115.postini.com ([64.18.6.12]) with SMTP; Sat, 29 Oct 2011 01:51:15 PDT Received: by faat9 with SMTP id t9so5876396faa.30 for ; Sat, 29 Oct 2011 01:51:12 -0700 (PDT) Received: by 10.223.75.25 with SMTP id w25mr12836908faj.15.1319878271720; Sat, 29 Oct 2011 01:51:11 -0700 (PDT) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi. [88.195.122.240]) by mx.google.com with ESMTPS id p14sm22795791faf.20.2011.10.29.01.51.10 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 29 Oct 2011 01:51:10 -0700 (PDT) Message-ID: <4EABBE7D.9080201@enterprisedb.com> Date: Sat, 29 Oct 2011 11:51:09 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.21) Gecko/20110831 Icedove/3.1.13 MIME-Version: 1.0 To: Albe Laurenz CC: pgsql-performance@postgresql.org Subject: Re: SSL encryption makes bytea transfer slow References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201110/269 X-Sequence-Number: 45491 On 28.10.2011 14:02, Albe Laurenz wrote: > We selected a 30MB bytea with psql connected with > "-h localhost" and found that it makes a huge > difference whether we have SSL encryption on or off. > > Without SSL the SELECT finished in about a second, > with SSL it took over 23 seconds (measured with > \timing in psql). > During that time, the CPU is 100% busy. > All data are cached in memory. > > Is this difference as expected? I tried to reproduce that, but only saw about 4x difference in the timing, not 23x. $ PGSSLMODE=disable ~/pgsql.master/bin/psql -h localhost postgres psql (9.2devel) Type "help" for help. postgres=# \o foo postgres=# \timing Timing is on. postgres=# SELECT repeat(xx,65536)::bytea FROM (SELECT string_agg(lpad(to_hex(x),2, '0' ),'') AS xx FROM generate_series(0,255) x) AS xx; Time: 460,782 ms $ PGSSLMODE=require ~/pgsql.master/bin/psql -h localhost postgres psql (9.2devel) SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) Type "help" for help. postgres=# \o foo postgres=# \timing Timing is on. postgres=# SELECT repeat(xx,65536)::bytea FROM (SELECT string_agg(lpad(to_hex(x),2, '0' ),'') AS xx FROM generate_series(0,255) x) AS xx; Time: 1874,276 ms oprofile suggests that all that overhead is coming from compression. Apparently SSL does compression automatically. Oprofile report of the above test case with SSL enabled: samples % image name symbol name 28177 74.4753 libz.so.1.2.3.4 /usr/lib/libz.so.1.2.3.4 1814 4.7946 postgres byteain 1459 3.8563 libc-2.13.so __memcpy_ssse3_back 1437 3.7982 libcrypto.so.0.9.8 /usr/lib/libcrypto.so.0.9.8 896 2.3682 postgres hex_encode 304 0.8035 vmlinux-3.0.0-1-amd64 clear_page_c 271 0.7163 libc-2.13.so __strlen_sse42 222 0.5868 libssl.so.0.9.8 /usr/lib/libssl.so.0.9.8 And without: samples % image name symbol name 1601 27.4144 postgres byteain 865 14.8116 postgres hex_encode 835 14.2979 libc-2.13.so __memcpy_ssse3_back 290 4.9658 vmlinux-3.0.0-1-amd64 clear_page_c 280 4.7945 libc-2.13.so __strlen_sse42 184 3.1507 vmlinux-3.0.0-1-amd64 page_fault 174 2.9795 vmlinux-3.0.0-1-amd64 put_mems_allowed Maybe your data is very expensive to compress for some reason? -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com