Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116913 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 90555 invoked from network); 22 Jan 2022 18:48:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Jan 2022 18:48:36 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A40251804DF for ; Sat, 22 Jan 2022 12:00:23 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 22 Jan 2022 12:00:23 -0800 (PST) Received: by mail-wm1-f47.google.com with SMTP id bg19-20020a05600c3c9300b0034565e837b6so10278520wmb.1 for ; Sat, 22 Jan 2022 12:00:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lablabs-io.20210112.gappssmtp.com; s=20210112; h=date:from:to:message-id:subject:mime-version; bh=oPOdSbqNBuJDs2rvw5MeyWQkEE4h7r5CTU8zg6myxYo=; b=ySgscAuXBjBZFL9SOWCl7QMowS4LdXQD3q7hVgsBBYlmjvruLaJaR9C38UYz7b8kU5 OJC5vDfoynAdPHhldzFy7Hxcag0ZpP+x4BXvA1l6rs41Hb3KP4BZs0u6FEMziuhfMFn1 QSYT8lsOw+JaLsvgC8/hlGzoIEBr812p1vICu+lzjVyr/C13hnBFIt5ZHaZe34aAaOgs LCfa2NF7I0ebkx+5LVaSwQJ4l9CrfbkqWSMLkIEky4dDiy8K4kqpuVuZ6nSDgtzSZGvb YRIoGratp204fOtQcj7StXT7ZpAsuKhgRfwEki0yvJCV0Scf+1MNG4T7gfksXaKlxTiP +uRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:message-id:subject:mime-version; bh=oPOdSbqNBuJDs2rvw5MeyWQkEE4h7r5CTU8zg6myxYo=; b=ZD7G1sszRDptgp33aogcC4pkU9g8VyXV8w1pCZv/ghPpNYvEa4vd2Wva9jibwP44VJ HYS8WNKsr/+/QXLzR0hM3QUiaRIrypaLgAMOQ6YXNgM8guDhywv7GeEu65UlYoQGRp/J Io0tAfR31+fSo6tlxFNyNB9YMqlDYQI4VCFoAWFKrRCiFqXAavWkL2uS1aIpR5lDir+F eJUOXcoDRdDPSKnYhEsHM9fTWjCS8iHUj36V7PR8fQMhqeYueWICaAzxWKHYnS/pa3ly cJOUX/djb5HytVdQrQ/VGJ1kmSotdUH2GK6b0kQFY8dT8WtoFHId/X+DEn+0HDFijz8H QUGw== X-Gm-Message-State: AOAM531WqQj/QYfsmgZ3SPSvtWchfHhgpHLp/dzbbWncThLWDg9rhamA roRBspSZUqWwJ4vEtrCUe3Lva1d1fYGfQg== X-Google-Smtp-Source: ABdhPJzmaxk+QjP3RM7pxRlqQBAKbTuyetWxTgO404ibIszfBX07tkF1kVpwHsLJLMVPVsBiGbxq3g== X-Received: by 2002:a1c:7402:: with SMTP id p2mr5498409wmc.53.1642881621892; Sat, 22 Jan 2022 12:00:21 -0800 (PST) Received: from [172.31.240.157] ([81.92.254.19]) by smtp.gmail.com with ESMTPSA id m5sm8686749wms.4.2022.01.22.12.00.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Jan 2022 12:00:21 -0800 (PST) Date: Sat, 22 Jan 2022 21:00:15 +0100 To: internals@lists.php.net Message-ID: X-Readdle-Message-ID: c2f04ec1-d62e-47ab-ac19-f43ab28101d7@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="61ec6254_5ff87e05_e489" Subject: Best way to monitor php-fpm container liveness on Kubernetes From: adam.hamsik@lablabs.io (Adam Hamsik) --61ec6254_5ff87e05_e489 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hello, We are using PHP for our application backends, this works very well as we= have developed s imple way to clone them with minimal effort(they can be= very similar). =46or our orchestration we are using Kubernetes (>=3D 1.2= 1). Our application pod generally contains NGINX + php-fpm and fluentbit = for log shipping. We generally want to have LivenessProbe(for an simple e= xplanation this is a simple check which is run against our pod to verify = if it's alive, if it fails particular container will be restarted). This works very we(we are also using swoole which is roughly 80-70% bette= r)l, but in certain unstable situations when we see higher application la= tency (db problem or a bug in our application). We often experience probl= ems, because pods are falsely marked as dead (failed liveness probe and r= estarted by kubelet). This happens all processes in our static pool are a= llocated to application requests. =46or our livenessProbe we tried to use= both fpm.ping and fpm.status endpoints but both of them behave in a same= way as they are managed with worker processes. I had a look at pgp-src repo if e.g. we can use signals to verify if appl= ication server is running as a way to go around our issue. When looking a= t this I saw fpm-systemd.c which is a SystemD specific check. This check = reports fpm status every couple seconds(configurable to systemd). Would y= ou be willing to integrate similar feature for kubernetes. This would be = based on a pull model probably with and REST interface. My idea is following: 1) During startup if this is enabled php-fpm master will open a secondary= port pm.health=5Fport(9001) and listen for a pm.health=5Fpath(/healtz)=5B= 2=5D. 2) If we receive GET request fpm master process will respond with HTTP co= de 200 and string ok. If anything is wrong (we can later add some checks/= metrics to make sure fpm is in a good state).=C2=A0=C2=A0If we do not res= pond or fpm is not ok our LivenessProbe will fail. based on configuration= this will trigger container restart. Would you be interested to integrate feature like this =3F or is there an= y other way how we can achieve similar results =3F =5B1=5D=C2=A0https://kubernetes.io/docs/concepts/workloads/pods/pod-lifec= ycle/=23when-should-you-use-a-liveness-probe =5B2=5D=C2=A0https://kubernetes.io/docs/reference/using-api/health-checks= / =C2=A0 =C2=A0Best Regards, =C2=A0 =C2=A0Adam. Adam Ham=C5=A1=C3=ADk Co-founder & CEO Mobile:=C2=A0+421-904-937-495 www.lablabs.io --61ec6254_5ff87e05_e489--