cloudamqp / amqproxy

An intelligent AMQP proxy, with connection and channel pooling/reusing
https://www.cloudamqp.com
MIT License
354 stars 54 forks source link

Strange timing #27

Closed stas-dovgodko closed 4 years ago

stas-dovgodko commented 4 years ago

48core*200G server with zero LA :

via proxy

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

use PhpAmqpLib\Connection\AMQPStreamConnection;
use PhpAmqpLib\Message\AMQPMessage;

$t1 = microtime(true);
$connection = new AMQPStreamConnection('localhost', 5673, 'guest', 'guest');

$channel = $connection->channel();

$channel->queue_declare('hello', false, true, false, false);

$msg = new AMQPMessage('Hello World!');
$channel->basic_publish($msg, '', 'hello');

echo " [x] Sent 'Hello World!'\n";

$channel->close();
$connection->close();

$t2 = microtime(true);

echo ($t2-$t1);
[x] Sent 'Hello World!'
0.35578203201294

direct to rabbitmq:

 [x] Sent 'Hello World!'
0.0085749626159668

355ms vs 8ms, what I'm doing wrong?

stas-dovgodko commented 4 years ago

Just switch kernel 4.19 -> 5.3 and looks like solved

carlhoerberg commented 4 years ago

oh wow, interesting. a strace/perf trace would have been needed to see if there was a syscall or function call that took extra long time in that kernel.

Co0ker commented 4 years ago

Hi @carlhoerberg , kernel 4.9 v0.3.7 = 0.040654897689819 v0.4.3 = 0.36057305335999

strace: https://dropmefiles.com/4zmB4

PavelvKalinin commented 4 years ago

any updates?

jamesmcminn96 commented 4 years ago

For amqproxy version 0.4.3 we're seeing this issue on kernels 5.3.0, 4.14.97 & 3.13.0.

We ended up downgrading to amqproxy version 0.3.7 like @Co0ker & the issue went away on all kernel versions.

@carlhoerberg, something erroneous may have happened somewhere in here https://github.com/cloudamqp/amqproxy/compare/v0.3.7...master?

jamesmcminn96 commented 4 years ago

@carlhoerberg I've narrowed it down to v0.4.1. v0.4.0 does not have the issue. https://github.com/cloudamqp/amqproxy/compare/v0.4.0...v0.4.1

carlhoerberg commented 4 years ago

Ok! Thank you for investigating. Might be the fact that we provided static builds from 0.4.1. Will provide dynamically linked builds again.

carlhoerberg commented 4 years ago

Maybe not, 0.4.0 was statically linked too :/

carlhoerberg commented 4 years ago

Ah, then I know, it's the TCP nodelay setting

carlhoerberg commented 4 years ago

0.4.4 enables TCP_NODELAY on all sockets: https://github.com/cloudamqp/amqproxy/releases/tag/v0.4.4