Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YzX98-0000IY-Ih for pgsql-performance@arkaria.postgresql.org; Mon, 01 Jun 2015 21:21:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YzX97-0006Od-NH for pgsql-performance@arkaria.postgresql.org; Mon, 01 Jun 2015 21:21:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YzX95-0006Kb-LB for pgsql-performance@postgresql.org; Mon, 01 Jun 2015 21:21:19 +0000 Received: from mail-wi0-f169.google.com ([209.85.212.169]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1YzX91-00020w-Uc for pgsql-performance@postgresql.org; Mon, 01 Jun 2015 21:21:18 +0000 Received: by wiwd19 with SMTP id d19so110213wiw.0 for ; Mon, 01 Jun 2015 14:21:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=8SeVKH/uILhsaUyAeWRvZHlUu9/GGxTRd0y4f0H1jzc=; b=Knnjt+AI1b1CLwXvoZ2nNk1tUBJuMeLA1BJOudVI2u0zms6qeHZd9pB5/GRWjLkH2L vo4KfU5SB/nUT5zOr7jgzUqoD0aiUckxWHr1aHwXYUre7bqtYzvpQXDXtXoNXeAmBX9o JEG8kzvjxbwVr0V6e1YsiDwqKzWQECRyy2zPSKS2DGuV2ybrx9l09nVV/LhzInOtC/XC he8/+/g06t8xxqLEAdEoego9C65XpcXrRJAGRouW44947ozVgAeSZTZz6YGNuGg6CApH jZos6iGWqrt8Oqbl4lXvjDR0HCaWk1Jo2+TECB+pydKjOfYqhdHQnYJrYEFNs/P2+p+D adPg== X-Gm-Message-State: ALoCoQkqxZOUgfIhubtTKyluqqng15vtku78uAEhf5WL1w/Kw9JrY/VuVTAy0CH/NhX8LXvSjpONg16rUwXQB5DjLI0iYPVtySWFnB7nKlis/nqbtsjC6FEXd7jmGiCA3rwLRZXoTlXCHLG/U8L6roGbssJokXR9byKhoo9tAKUTMb+GKDhETk8G/QtuRYnsGt1RrIDqH3CvY5idR9p5h4+7ydBQPtv6XQ== X-Received: by 10.194.63.228 with SMTP id j4mr45212693wjs.38.1433193674298; Mon, 01 Jun 2015 14:21:14 -0700 (PDT) Received: from [10.137.2.12] (ip-78-45-136-74.net.upcbroadband.cz. [78.45.136.74]) by mx.google.com with ESMTPSA id ei8sm23669557wjd.32.2015.06.01.14.21.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2015 14:21:13 -0700 (PDT) Message-ID: <556CCCC6.6030109@2ndquadrant.com> Date: Mon, 01 Jun 2015 23:21:10 +0200 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Connection time when using SSL References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Hi On 06/01/15 22:51, Marco Di Cesare wrote: > I am connecting to a Postgres instance using SSL and seeing fairly slow > connect times. I would expect there would be some overhead but it's more > than I anticipated. The connection is happening over a network. I am > using a wildcard SSL certificate on the server side only. > Using one of these JDBC SSL connect strings takes on average: 1060 ms to > connect to the database: > jdbc:postgresql://db01-dev.pointclickcare.com:5432/testdb?ssl=true&sslmode=require&sslfactory=org.postgresql.ssl.jdbc4.LibPQFactory > - or - > jdbc:postgresql://db01-dev.pointclickcare.com:5432/testdb?ssl=true&sslmode=require&sslfactory=org.postgresql.ssl.NonValidatingFactory > Using this JDBC non-SSL connect string takes on average: 190 ms to > connect to the database: > jdbc:postgresql://db01-dev.pointclickcare.com:5432/testdb > Does this sound like a reasonable overhead that SSL would add to the > connection time or does this seem high? (~870ms/~443% slower using SSL) What is the network latency (ping) between the two hosts? SSL requires a handshake, exchanging a number messages between the two hosts, and if each roundtrip takes a significant amount of time ... The 190ms seems quite high. On my rather slow workstation, a local connection without SSL takes ~30ms , with SSL ~70ms. So I wouldn't be surprised by ~100ms roundtrips in your case, and that is going to slow down the SSL handshake significantly. There's very little you can do with the roundtrip time, usually, but you can keep the connections open in a pool. That'll amortize the costs. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance