Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126244 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id AE03F1A00BC for ; Thu, 30 Jan 2025 16:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738255173; bh=67RuNKb6pZGmnZ7SHtUUopCfwBG8CtADkYyMPQmyzJM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=lyTmX3ICf2KwmxiRdT6Wbx/8hMlWLCiz7vTM3OGK8TDM8qL9c4pGVe3cyTcaRJqhl Wbr5/swmoOUVIy7xjdtnpm8P/Z6WV1FHT8fz5rQC75xBH9H1NKX0WSvhJh2pq99Lhf 7AJ6FuT9L8sytpo8sEKgDCQ90oxsa/TUnGt2p0iFXXws5muJn5uEmPvm9MsgQ3h/ge qlHt2dBGKSLvhPxttzTSOAqxht4WBTRM/3Zc4FQzLZEw0lQyoP3/l9wFnJSkTnbUtB TGSA8rx12FQ5WGLeynpIr/A/AIdfRhCu/Df+Wg+0zV9Vw8sEx1LGCEaTs0XQoi5xA6 mbBkEanSUOzGw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 24DCC180082 for ; Thu, 30 Jan 2025 16:39:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 30 Jan 2025 16:39:32 +0000 (UTC) Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-4678664e22fso10220611cf.2 for ; Thu, 30 Jan 2025 08:42:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ethaniel.com; s=google; t=1738255339; x=1738860139; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=67RuNKb6pZGmnZ7SHtUUopCfwBG8CtADkYyMPQmyzJM=; b=maL+3jenhIx+ibGsor1T0X4J+bTvUn9iehSQOJPnTgp/DO/tCTlyutR71jJtzocMk7 kF63rbMGgbVK4bcteXeyNWYIaRjLX+4vG0wS0CQIc5MxBTHcwbi1Ecfj8ktRzbSmPQaS nSqe4KMEOxUv3ozJZ9OcWB0Y9i+JsA66q4ulo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738255339; x=1738860139; 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=67RuNKb6pZGmnZ7SHtUUopCfwBG8CtADkYyMPQmyzJM=; b=Xt1T7CD7SeBOkRMeU1cXy6O1pjpOA3/bemFRydTK+nvl219sq6ZiTey/3mOY8RPvTG xVOBJPJPX7mbZ2l+zXJzymhwpJTPWWT7ccQOiXTCAGT4xw/UYAJjwVeKQ3W8X4yszE2j B8nEAcEL1sE31oK4tgwt9k4U9FYXQecBm2pSVmDCQQUM1apjANxtFVOAfriR6mr+oAR8 XYOSNxMw4a4oP/i3wMlUxo2STJjX+xtVoV9EUXLyhv1s710P/GYnY3qBgO6MNAiXrd/e jFBa/H/Lb9l+JUZcuM2Qad8IMecR8AuqHfGi8zRylX9EV+cJmE500tp79vv0EW/4rKoF nm6A== X-Gm-Message-State: AOJu0Yw50diUaaNB+a5Ll2w8mCTizP0gB7lUoYUStu4esOHjVMq4bIxA ZcLQ33wYFvTvaQLcNYCwTbbzXDzsGpO0ZKdck/F66uuiq4NzpjvCLvqOv5BwBxUV+8hp0kckCCP tfBUzF5aijeVydWGsJbOzq6yBlQ9+5UtSuHhma0lrk9QGJHH1NZ/p X-Gm-Gg: ASbGnctH98z+eMuWNpn6EmnCn40M521lLZhpimP6UgQts4KxmsSAMTshVuhOTIDuo47 8MShTpdSAI3kH2gLImOKzE6d9COEnBBU0EB3rncXavqaqxIoDtwu7MVONCtKmPtlVQAIqrPrih1 k= X-Google-Smtp-Source: AGHT+IEcddZyl1pIA0dTLXSZhj+096CGim9FMknyWSToRsMfd+9JzEyXhl6H4HEdvqWR1CXt4dUHlMseCAovZ0af3t4= X-Received: by 2002:a05:622a:5c16:b0:467:652a:2c77 with SMTP id d75a77b69052e-46fd0a12d32mr127797911cf.3.1738255339586; Thu, 30 Jan 2025 08:42:19 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 30 Jan 2025 10:41:53 -0600 X-Gm-Features: AWEUYZmJtwKdeuuxIVYUHLWlYHvXyaeC_evUDKwJpaRu3lswXhC5IO_xg0b5ZDA Message-ID: Subject: Re: [PHP-DEV] [RFC] Introducing pm.max_memory for PHP-FPM To: Jakub Zelenka Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000000b9349062cef1c47" From: eth@ethaniel.com (Arkadiy Kulev) --0000000000000b9349062cef1c47 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello! This wouldn't really work because FPM does not control the script during > execution and would have to check it out after each allocation which is n= ot > really viable. > Thanks for the feedback! I agree that monitoring memory usage after each allocation would be infeasible. However, my suggestion was actually to check memory usage *only once per request*, specifically at request shutdown, when FPM regains control and before assigning another request to that worker. We already have hooks for request startup and request shutdown in FPM. Could we simply insert a memory check at the request shutdown stage=E2=80= =94where the worker is returning control to the FPM master process=E2=80=94before pi= cking up a new request? Just to be clear, "memory_limit" helps kill runaway scripts mid-request. By contrast, the newly proposed pm.max_memory is meant to catch processes with a slow leak across multiple requests. We only need to check at the end of each request, which is presumably when the worker returns control to FPM. --0000000000000b9349062cef1c47 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello!

This wouldn&= #39;t really work because FPM does not control the script during execution = and would have to check it out after each allocation which is not really vi= able.

Thanks for the feedback! = I agree that monitoring memory usage after each allocation would be infeasi= ble. However, my suggestion was actually to check memory usage only once= per request, specifically at request shutdown, when FPM regains contro= l and before assigning another request to that worker.=C2=A0

We already have hooks for request startup and request shut= down in FPM. Could we simply insert a memory check at the request shutdown = stage=E2=80=94where the worker is returning control to the FPM master proce= ss=E2=80=94before picking up a new request?

Ju= st to be clear, "memory_limit" helps kill runaway scripts mid-req= uest. By contrast, the newly proposed pm.max_memory is meant to catch proce= sses with a slow leak across multiple requests. We only need to check at th= e end of each request, which is presumably when the worker returns control = to FPM.
--0000000000000b9349062cef1c47--