Backend
Octane

Performance

MetaFox is based on laravel framework, take a look over request lifecycle. By default laravel bootstrap process requires two many files & services, in default packages there are ~ 1300 files and 130 services need to register and bootstrap.

Request Lifecycle

laravel request lifecycle

laravel request lifecycle

laravel request lifecycle

FPM Server

fpm container

Octane Server

octane server

Compare FPM Vs Octane

wrk -c100 -t4 "htttp://api.metafox.test/me"

fpm

octane

Best Practise

Dependency Injection

https://laravel.com/docs/10.x/octane#configuration-repository-injection (opens in a new tab)

register_shutdown_function

register_shutdown_function => Lifecycle::onRequestTerminated

Memory leak

/**
 * Handle an incoming request.
 */
public function index(Request $request): array
{
    Service::$data[] = Str::random(10);
 
    return [
        // ...
    ];
}
php