Skip to content

[Question] About parallel requests #419

Closed

Description

@foremtehan

I'm curious to know if frankenphp can effectively manage multiple incoming requests simultaneously. Does it spawn processes similar to fpm?

<?php

echo "here\n";

sleep(2);

if five users request this script simultaneously, does it take 2 seconds or 10 seconds?

Activity

  1. withinboredom commented on Dec 21, 2023

    @withinboredom
    Member

    For each request, there'll be a 2-second wait... the real answer is: "it depends."

    For example, if you have 2 cores in cgi-mode: the first two requests will take 2 seconds, with the remaining 3 requests will wait for the first two requests to finish in a queue. So these first two requests will wait two seconds, the next two, four seconds, and the final one six seconds. You can override this with the num_threads setting in your Caddyfile:

    frankenphp {
    		num_threads 48
    	}
    

    In worker mode, you can override the number of workers, for example, for 48 workers:

    frankenphp {
    		worker testdata/index.php 48
    	}
    

    This means the first 48 requests would only have to wait 2 seconds. Therefore all 5 requests would be handled simultaneously.

    Does that help?

  2. nickchomey commented on Dec 21, 2023

    @nickchomey
    Contributor

    Surely there's some limit to the number of workers though, no? You can't just set it to 100k workers. You'd have to set the workers relative to the available computing resources as well as how compute-intensive the application is - finding some equilibrium that maximizes throughout. Any tips for that?

  3. foremtehan commented on Dec 22, 2023

    @foremtehan
    Author

    Thanks

    I hope it will have similar behavior to fpm, which spawns processes and does not depend on my cores but rather on memory.

    I can't test it out because it doesn't have support for Linux/arm64.

  4. withinboredom commented on Dec 22, 2023

    @withinboredom
    Member

    Surely there's some limit to the number of workers though, no?

    Yes, hardware/OS limits. If your hardware can handle 100k threads, you can configure 100k threads.

    You'd have to set the workers relative to the available computing resources as well as how compute-intensive the application is - finding some equilibrium that maximizes throughout. Any tips for that?

    It largely depends on whether you're memory and/or CPU-constrained (on the hardware level), your application and its memory/CPU usage.

    It takes some art to get it to the best like tuning fpm. However, if you already have fpm configured, it will likely be about the same (if not less).

    I hope it will have similar behavior to fpm, which spawns processes and does not depend on my cores but rather on memory.

    Yes, it spawns processes like fpm (fpm doesn't care about memory though, or how many cores you have). However, the default number of maximum processes is very different. IIRC, FPM defaults are some incredibly low numbers, like 10 workers, but Frankenphp's default is something like 2x the number of cores on your machine. So, it may require tuning, just like any other server software, to find the right balance for your application.

    I can't test it out because it doesn't have support for Linux/arm64.

    @dunglas, are we just missing a build here, or does it not support arm64? I think we are just missing a build in the build matrix.

  5. added a commit that references this issue on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions