Swoole-src: How to speed up swoole on larger payloads?

Created on 27 Jan 2019  ·  2Comments  ·  Source: swoole/swoole-src

I encounter a performance decrease of 15x when payload in $response->end() reaches 1MB and up.

This happens even when on localhost. So network must not be the issue. How to speed up swoole on larger payloads?

These is a sample code I used:

<?php
define('BASE_DOMAIN', 'swoole-tests.local.com');
define('PORT', 9501);
define('BASE_URL', 'http://' . BASE_DOMAIN);

$http = new swoole_http_server(BASE_DOMAIN, PORT);

$http->on('start', function ($server)
{
    echo 'Swoole http server is started at ' . BASE_URL . ' on port ' . PORT;
});

$http->on('request', function ($request, $response)
{
    $response->header('Content-Type', 'text/plain');
    $response->end('Hello world');
});

$http->start();
question

Most helpful comment

The amount of data is too large, bandwidth is the bottleneck.

1Mb * 1024 (request) = 1G bytes , This requires 8G network bandwidth.

Even if it is a local communication, it does not necessarily have such a large throughput.

All 2 comments

The amount of data is too large, bandwidth is the bottleneck.

1Mb * 1024 (request) = 1G bytes , This requires 8G network bandwidth.

Even if it is a local communication, it does not necessarily have such a large throughput.

You were right, Bandwidth was the Bottleneck, I was already reaching 38Gb/s. Max of my setup is I think 40Gb/s. How was swoole able to leverage zero-copy?

Was this page helpful?
0 / 5 - 0 ratings