Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sxlx0-00CIFr-V9 for pgsql-general@arkaria.postgresql.org; Mon, 07 Oct 2024 11:30:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sxlwz-009x4a-9N for pgsql-general@arkaria.postgresql.org; Mon, 07 Oct 2024 11:30:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sxlwy-009x4P-QO for pgsql-general@lists.postgresql.org; Mon, 07 Oct 2024 11:30:52 +0000 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sxlwv-002wc8-SX for pgsql-general@postgresql.org; Mon, 07 Oct 2024 11:30:51 +0000 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-6e2e4244413so12743317b3.3 for ; Mon, 07 Oct 2024 04:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728300649; x=1728905449; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=xhf54r1duKlFkkQgchBXpyJLPXkl1TdD6VbGXRFyc7k=; b=HFf5XdJ6gAEtsp3BBCgrweVVN95HPjnGsDg17PbTT40XJar6fmpWPhgpb1Itq/WxWC J5jWMSVJCEFsf64lxGgnVuC6svrjb4mQwaODh3eMM6rYyeydC+mFMeYlraNjA+vTyL78 ckXWyG+Ok1Ux7cFcEEfYRoANLhZTrpBu2zV93whms3oMWeEdGUtX2QdovVee4CwObu1S Ub436Vm0JQanvQptiaPy6mjHCwQGGdFHzitSbRCOp0S69W+OyycTGNVnWsfrrvQtwsb5 eDfNM3lFqrUwTPnypOaSsETRKk+3QA1Evf8lTikhXVMFvKrGMKI0xNN9/eAu89VvhMnZ eNRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728300649; x=1728905449; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xhf54r1duKlFkkQgchBXpyJLPXkl1TdD6VbGXRFyc7k=; b=L9xDeWYCmVDcdeMYRUgX3fRAZ2oS0+gyAZniv4dXuBSkTHVqCGAFKOqlOQmyxLlsyi MbT1gBwIN5fjnPq19lSh9B2ZuH54i63eGIO0dcAFjDtssvV9y4rQ22zXt/IfpBLd1+AA L9i7KJVI07WwXykLlRBcWwzkoOu9d5eeT5NkbfHSy4lQL9S+JyG6+pcVAkOzZ9a5CvWn YO60TKQ3bkOs9uw1MppGo8N6jY9uRIi8+XajPZbvzBtooMJvsJngF71FP3CXpdeRxM/l cLWJDZq/XVDFvyt7kO2lB+uGkmy++WQ+h03HRPpwxvvDkfLeiwJtwUveoW4aRiESMfnE eMYg== X-Gm-Message-State: AOJu0YwG6gbcQNcCwrwR4oZjrVF89nivKrG5hJcfgdvUurm8pdE/ZHrU c9eARdkhbwiVLo9Ru5pLvFSoqWKymNiaiUphjoiSIbJmsXXRQ+5u0JVKjtwzAVwb23YGovshOtf cKUmx+UGlMLgPTfBtQCq1EkcRUA8= X-Google-Smtp-Source: AGHT+IGs/0WMZgWvIj8jKISeQtzPs7HeXT2DwRmgFsYZJHZ8sPYJTWpRES3f5VSZKg8bgJijJOgSSA+PZd+QRAC7S78= X-Received: by 2002:a05:690c:360d:b0:6c3:7d68:b400 with SMTP id 00721157ae682-6e2c7028797mr86644327b3.10.1728300648638; Mon, 07 Oct 2024 04:30:48 -0700 (PDT) MIME-Version: 1.0 References: <202410061837.u5y5zwsxcpfb@alvherre.pgsql> In-Reply-To: <202410061837.u5y5zwsxcpfb@alvherre.pgsql> From: KK CHN Date: Mon, 7 Oct 2024 17:00:47 +0530 Message-ID: Subject: Re: CLOSE_WAIT pileup and Application Timeout To: Alvaro Herrera Cc: pgsql-general Content-Type: multipart/alternative; boundary="0000000000003a2f9b0623e15a67" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000003a2f9b0623e15a67 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Oct 7, 2024 at 12:07=E2=80=AFAM Alvaro Herrera wrote: > On 2024-Oct-04, KK CHN wrote: > > > The mobile tablets are installed with the android based vehicle > > tracking app which updated every 30 seconds its location fitted inside > the > > vehicle ( lat long coordinates) to the PostgreSQL DB through the java > > backend application to know the latest location of the vehicle and its > > movement which will be rendered in a map based front end. > > > > The vehicles on the field communicate via 443 to 8080 of the Wildfly > > (version 27 ) deployed with the vehicle tracking application developed > with > > Java(version 17). > > It sounds like setting TCP keepalives in the connections between the > Wildfly and the vehicles might help get the number of dead connections > down to a reasonable level. Then it's up to Wildfly to close the > connections to Postgres in a timely fashion. (It's not clear from your > description how do vehicle connections to Wildfly relate to Postgres > connections.) > > Where do I have to introduce the TCP keepalives ? in the OS level or application code level ? [root@dbch wildfly-27.0.0.Final]# cat /proc/sys/net/ipv4/tcp_keepalive_time 7200 [root@dbch wildfly-27.0.0.Final]# cat /proc/sys/net/ipv4/tcp_keepalive_intv= l 75 [root@dbch wildfly-27.0.0.Final]# cat /proc/sys/net/ipv4/tcp_keepalive_probes 9 [root@dbch wildfly-27.0.0.Final]# These are the default values in the OS level. Do I need to reduce all the above three values to say 600, 20, 5 ? Or need to be handled in the application backend code ? Any hints much appreciated.. > > I wonder if the connections from Wildfly to Postgres use SSL? Because > there are reported cases where TCP connections are kept and accumulate, > causing problems -- but apparently SSL is a necessary piece for that to > happen. > No SSL in between Wildfly (8080 ) to PGSQL(5432). Both the machines internal lan VMs in the same network. Only the devices on the field (fitted on the vehicles) communicate to the application backend via a public URL :443 port then it connectes to the 8080 of wildfly then the java code connects the database server running on 5432 on the internal LAN network. > > -- > =C3=81lvaro Herrera 48=C2=B001'N 7=C2=B057'E =E2=80=94 > https://www.EnterpriseDB.com/ > Thou shalt study thy libraries and strive not to reinvent them without > cause, that thy code may be short and readable and thy days pleasant > and productive. (7th Commandment for C Programmers) > --0000000000003a2f9b0623e15a67 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Mon, Oct 7, 2024 at 12:07=E2=80=AF= AM Alvaro Herrera <alvherre@a= lvh.no-ip.org> wrote:
On 2024-Oct-04, KK CHN wrote:

> The mobile tablets are installed with the android based vehicle
> tracking app which updated every 30 seconds its location fitted inside= the
> vehicle ( lat long coordinates) to the PostgreSQL DB through the java<= br> > backend application to know the latest location of the vehicle and its=
> movement which will be rendered in a map based front end.
>
> The vehicles on the field communicate=C2=A0 via 443 to=C2=A0 =C2=A0808= 0 of the Wildfly
> (version 27 ) deployed with the vehicle tracking application developed= with
> Java(version 17).

It sounds like setting TCP keepalives in the connections between the
Wildfly and the vehicles might help get the number of dead connections
down to a reasonable level.=C2=A0 Then it's up to Wildfly to close the<= br> connections to Postgres in a timely fashion.=C2=A0 (It's not clear from= your
description how do vehicle connections to Wildfly relate to Postgres
connections.)


Where do I have to introduce the TCP k= eepalives ? in the OS level or application code level ?

[root@dbch wildfly-27.0.0.Final]# cat /proc/sys/net/ipv4/tcp_keepaliv= e_time
7200
[root@dbch wildfly-27.0.0.Final]# cat /proc/sys/net/ipv4/= tcp_keepalive_intvl
75
[root@dbch wildfly-27.0.0.Final]# cat /proc/sy= s/net/ipv4/tcp_keepalive_probes
9
[root@dbch wildfly-27.0.0.Final]#

These are the default values in the OS level.= =C2=A0 =C2=A0Do I need to reduce all the above three values to=C2=A0 say 60= 0, 20, 5=C2=A0 ?=C2=A0 =C2=A0Or need to be handled in the application backe= nd code ?=C2=A0

=C2=A0Any hints much appreciated..=

I wonder if the connections from Wildfly to Postgres use SSL?=C2=A0 Because=
there are reported cases where TCP connections are kept and accumulate,
causing problems -- but apparently SSL is a necessary piece for that to
happen.
No SSL in between=C2=A0 =C2=A0Wildfly (8080 ) = to=C2=A0 =C2=A0 PGSQL(5432).=C2=A0 Both the machines internal lan VMs=C2=A0= in the same network.=C2=A0 =C2=A0 Only the devices on the field (fitted on= the=C2=A0 vehicles) communicate to the application backend via a public UR= L :443=C2=A0 port=C2=A0 then=C2=A0 it connectes=C2=A0 to the 8080 of wildfl= y then the java code connects the=C2=A0 database server running on 5432 on = the internal LAN network.
=C2=A0
--
=C3=81lvaro Herrera=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A04= 8=C2=B001'N 7=C2=B057'E=C2=A0 =E2=80=94=C2=A0 https://www.Enter= priseDB.com/
Thou shalt study thy libraries and strive not to reinvent them without
cause, that thy code may be short and readable and thy days pleasant
and productive. (7th Commandment for C Programmers)
--0000000000003a2f9b0623e15a67--