keepwalking
keepwalking

Reputation: 2654

Lumen slow response

Looks like i am getting a big difference on the following test

$app->get('/', function () {
    return ['test' => 1];
});

This takes about 450ms and returns {'test': 1}

The following

$app->get('/', function () {
    echo json_encode['test' => 1];
    exit;
});

This takes about 170ms which is a big difference especially when you have a lot of requests to your api.

So probably something heavy happens in the response factory but i could not find it nor i could find a way to overwrite it with my own method. Any ideas?

Thanks

Update

Looks like the following line in Symfony\Component\HttpFoundation its adding 250 extra ms. Not sure why right now.

header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);

Which outputs

header('HTTP/1.0 200 OK1200');

Upvotes: 2

Views: 1187

Answers (1)

keepwalking
keepwalking

Reputation: 2654

It looks like the following line: header('HTTP/1.0 200 OK1200'); in Symfony\Component\HttpFoundation is causing the extra 250ms. So I guess its not related to lumen

Upvotes: 1

Related Questions