Improve D8 performance to access a custom REST controller
Given I did not have many responses, I answer myself to share the bits of explanation and solution I found.

Below the performance loss sources I've identified :


The use of D8 full bootstrap, including modules loading, routes resolving, etc.
Reading and parsing a YAML config file each time the module handles a request


And the solutions I applied :

Custom D8 minimal bootstrap

Based on this post and the default D8 index.php, I created a custom Bootstrap in my proxy module :

use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
use Drupal\my_module\Controller\ProxyController;

chdir( $_SERVER['DOCUMENT_ROOT'] );

$autoloader = require_once 'autoload.php';

$request = Request::createFromGlobals();
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$kernel-&gt;boot();
$container = $kernel-&gt;getContainer();

$response = ProxyController::create( $container )-&gt;index( $request );
$response-&gt;send();

$kernel-&gt;terminate($request, $response);


Like it was made in the D7 version, I redirected all request with the /service prefix to this file.

PHP config instead of YAML

I didn't find a way to load and parse the YAML config file once and cache the result.
(I'm still interested if someone know how to do that by the way)

So i converted the config file content myself into PHP, put it into a .php file and
use include instead of file_get_contents() and Yaml::decode().

Result

You can see here the response time obtained combining the 2 solutions above.



I assume the remaining perf loss is due to the use of OOP instead of procedural PHP. But if I want to stick to the D8 standards, I can't do much about it...