this post was submitted on 27 Jan 2025
4 points (100.0% liked)

PHP

575 readers
1 users here now

Welcome to /c/php! This is a community for PHP developers and enthusiasts to share and discuss anything related to PHP. From the latest updates and tutorials, to your burning questions and amazing personal projects, we welcome all contributions.

Let's foster an environment of respect, learning, and mutual growth. Whether you're an experienced PHP developer, a beginner, or just interested in learning more about PHP, we're glad to have you here!

Let's code, learn, and grow together!

founded 2 years ago
MODERATORS
 

I noticed that if you have too few pm_children set then some requests hang until timeout. This surprised me - I'd expect an immediate error, but it's more like a tarpit! For ages I was thinking my server was not performant, then I noticed via top that it wasn't doing or waiting while the browser was.

I have two questions:

  1. If you have pm_max_children=1 and you occupy that and submit another request, what actually happens? (I'm proxying through nginx.) HTTP doesn't have a "40_ Come back later".

  2. (if life deals you lemons...) if you can generate a tarpit that doesn't use server resources, this could be quite useful to know about too!

top 3 comments
sorted by: hot top controversial new old
[–] Max_P@lemmy.max-p.me 3 points 2 days ago (1 children)

FPM uses a request queue, so when all workers are busy they wait in line until a worker frees up to process it. With just 1 worker, this can take a long time to catch up, but with a reasonable number of workers you'll only wait a few seconds or even milliseconds depending on the app and how fast it can process requests.

The setting for that is listen.backlog which defaults to 511 on Linux.

[–] nettie@lemmy.world 1 points 2 days ago (1 children)

Right Thanks. So I think php might queue then forget some requests, because I've had this behaviour without too much traffic. I just don't know how to reproduce it, but maybe I'll try with that listen backlog setting, thanks for tip.

[–] Max_P@lemmy.max-p.me 2 points 2 days ago

It doesn't forget requests, but NGINX will drop them after it times out if it takes too long.