Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client slow with Telegram urls #156

Closed
cheeghi opened this issue Apr 2, 2020 · 1 comment
Closed

Client slow with Telegram urls #156

cheeghi opened this issue Apr 2, 2020 · 1 comment
Labels

Comments

@cheeghi
Copy link

cheeghi commented Apr 2, 2020

Hi,
I'm using reactphp-buzz (2.7) and I found it really slow trying to perform a GET request towards Telegram servers. I've compared it with synchronous GuzzleHttp and this one seems 5 times faster than buzz. The weird thing is that this happens only with Telegram servers' urls, trying with another domain the performance is more or less the same. Here my test scripts (PHP 7.3.3):
This one using Guzzle (sync):

<?php

use GuzzleHttp\Client;

require __DIR__ . '/../../vendor/autoload.php';

$client = new Client();
$uri = "https://core.telegram.org/bots";
//$uri = "http://dummy.restapiexample.com/api/v1/employees";

$start = microtime(true);
$client->get($uri);
$end = microtime(true);

echo $end - $start;

Which takes about 0.15s to be executed.

This one with reactphp-buzz (async):

<?php

require __DIR__ . '/../../vendor/autoload.php';

$loop = \React\EventLoop\Factory::create();

$browser = new \Clue\React\Buzz\Browser($loop);
$uri = "https://core.telegram.org/bots";
//$uri = "http://dummy.restapiexample.com/api/v1/employees";

$start = microtime(true);
$browser->get($uri)->then(function (\Psr\Http\Message\ResponseInterface $response) use (&$start) {
    $end = microtime(true);
    echo $end - $start;
});

$loop->run();

Which takes about 0.75s to be executed.

If I try to use the commented url (http://dummy.restapiexample.com/api/v1/employees) instead of the Telegram one the request response times are more ore less the same.

Am I missing something or using reactphp-buzz in the wrong way? Maybe Guzzle is passing some "under the hood" parameters that makes Telegram servers reply quicker?

Thank you in advance, Michele

@clue clue added the question label Apr 21, 2020
@clue
Copy link
Owner

clue commented Apr 21, 2020

@cheeghi Thanks for reporting, this is an interesting one! 👍

Unfortunately, I can not reproduce the problem you're seeing. Both curl and this project take approximately the same time in my tests (~150ms).

It's a bit hard to diagnose without having a better insight into the particular network parameters and setup, but I don't see anything obvious that would cause this kind of difference. The only issue we're aware of would be misbehaving HTTP servers as briefly discussed in #102, but this is very rare in practice.

I believe this has been answered, so I'm closing this for now. Please come back with more details if this problem persists and we can reopen this 👍

@clue clue closed this as completed Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants