Skip to content

Worker mode not working as expected #2477

@come-nc

Description

@come-nc

What happened?

Hello,

I am trying to use worker mode for a few endpoints (see nextcloud/server#61115).
Looking at metrics, it looked like worker mode was only used for one of them, index.php, but not remote.php.
I wondered whether the match was needed so I added match index.php/* and match remote.php/* to the workers.
First surprise was that this doubles the number of workers, because I now have index.php and index.php_0 listed and same for remote.php.

So I am not sure whether this is needed and how it should actually be configured. The documentation shows worker configuration without any match and does not state whether that limits it to direct hit (/index.php) and how to extend it to all subpaths targeting this endpoint.
This is hard to debug also because I’m unsure how I could detect whether a request goes through worker mode or is wired outside of it?

Current Caddyfile I’m testing with:

{
        metrics
        frankenphp {
                num_threads 192
                max_threads 256
                max_requests 500
                php_ini memory_limit 512M
        }
}

localhost:81 {
        php_server {
                worker {
                        file index.php
                        num 32
                        watch
                        match /index.php/*
                }
                worker {
                        file remote.php
                        num 16
                        watch
                        match /remote.php/*
                }
                worker {
                        file ocs/v1.php
                        num 16
                        watch
                        match /ocs/v1/.php/*
                }
                worker {
                        file ocs/v2.php
                        num 16
                        watch
                }
        }

        log {
                level ERROR
                output stderr
        }

        encode gzip

        redir /.well-known/carddav /remote.php/dav 301
        redir /.well-known/caldav /remote.php/dav 301

        # Rule: Maps most RFC 8615 compliant well-known URIs to our main frontend controller (/index.php) by default
        @wellKnown {
                path "/.well-known/"
                not {
                        path /.well-known/acme-challenge
                        path /.well-known/pki-validation
                }
        }
        rewrite @wellKnown /index.php

        rewrite /ocm-provider/ /index.php

        @forbidden {
                path /.htaccess
                path /data/*
                path /config/*
                path /db_structure
                path /.xml
                path /README
                path /3rdparty/*
                path /lib/*
                path /templates/*
                path /occ
                path /build
                path /tests
                path /console.php
                path /autotest
                path /issue
                path /indi
                path /db_
                path /console
        }
        respond @forbidden 404
}

I’m also interested in general advices about how to setup/structure the Caddyfile by the way ^^

Build Type

Static binary

Worker Mode

Yes

Operating System

GNU/Linux

CPU Architecture

x86_64

PHP configuration

phpinfo() output
How do I get that not in html?
I tried franken php-cli phpinfo.php and it still output html.
That’s a huge chunk of text I’m not sure what to censor in. Please provide easier information how to get it in the issue template.

Relevant log output

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions