Skip to content

HTTP client on specific network shows poor performance #494

@Exanlv

Description

@Exanlv

Depending on network configuration, making HTTP requests can be extremely slow.

Using the code below, I compared React HTTP with Guzzle HTTP. React is far slower

image

This only occurs on my work's network, when doing this test on the exact same machine at home, this is not an issue. (It's about 6km of physical distance so that's negligible)

I can't get access to the router config to look around at the settings, if there's any specific configuration that you'd like to know about this network I could ask.

<?php

use GuzzleHttp\Client;
use React\Http\Browser;
use RingCentral\Psr7\Request;

use function React\Async\await;

require './vendor/autoload.php';

if (count($argv) < 2) {
    die('Specify which HTTP lib to use');
}

$requests = [
    new Request(
        'GET',
        'https://google.com/'
    ),
    new Request(
        'GET',
        'https://postman-echo.com/get'
    ),
];

$time = microtime(true);

if ($argv[1] === 'react') {
    $browser = new Browser();

    foreach ($requests as $request) {
        await($browser->request($request->getMethod(), $request->getUri()));
    }
} elseif ($argv[1] === 'guzzle') {
    $client = new Client();

    foreach ($requests as $request) {
        $client->request($request->getMethod(), $request->getUri());
    }
} else {
    die('Invalid test subject');
}

echo sprintf('Completed in %f seconds', microtime(true) - $time), PHP_EOL;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions