-->
Page 5 of 7

Re: Http download speed

PostPosted: Mon Aug 22, 2016 3:44 pm
by Vicne
Edit: this post exhibits disappointing results of the Async server due to my wrong use of it. See a post further below for updated resutls.

Hi, all,
I had some time to make semi-scientific measurements and compare the classic ESP8266WebServer and the AsyncWebServer, both under the current 2.3.0 version of the ESP8266 "cores" (boards package) as well as under the git as of Aug. 19, 2016 (I call it 2.4.0-pre).
Both servers were used to implement a dynamic page which generates dummy content of custom size.
Then, each of the 4 versions (2 libs * 2 core version) was called:
- first to download 4 payloads of 100KB in sequence (4 wget in a batch, called in turn), and the total time was measured
- then to download the same 4 payloads in parallel (the time was measured being between the start of the script and the end of the slowest download)
And that cycle was repeated 10 times to get a representative average.
All those 80 numbers were collected and compared, but I think a chart is worth a thousand numbers:
[attachment=0]image.png[/attachment]
Conclusions ?
With current production cores (2.3.0), transfer is slow with the standard ESP8266WebServer (around 180kbps, no matter if you use call in parallel or in sequence). If you use the AsyncWebServer lib and perform the calls in parallel, you get an important gain (factor 2: 350 kbps), not counting the fact that your loop() can now do work in the meantime.
But what really gives a huge boost is the cores in the current git (2.4.0-re), where speed gains almost a factor 10 with the standard ESP8266WebServer (around 1500kbps). Surprisingly though the AsyncWebServer does not gain any boost with these cores, so I guess an update of the lib will be needed.

All comments are welcme of course.

Kind regards,

Vicne

Re: Http download speed

PostPosted: Mon Aug 22, 2016 5:20 pm
by bbx10node
Nice work! I would have guessed async web server parallel with 2.4.0-pre would be the fastest but the data shows otherwise.

Re: Http download speed

PostPosted: Mon Aug 22, 2016 5:39 pm
by Me-no-dev
change in between 2.3.0 and 2.4.0-pre is in the regular TCP client, which has nothing to do with Async TCP lib, therefore there should be no change at all.
This change is kinda mix between async and sync and is causing issues with some libraries and is mixing the loop context with the system context (where async runs).
Since the regular TCP Client is almost blocking to send the data as fast as possible, I'm not surprised by the results. Running async does not force any delay on any other service / loop code running elsewhere.
Results also depend on what is your loop doing, how busy is your network with others :)

You mind sharing your test sketches?

Re: Http download speed

PostPosted: Mon Aug 22, 2016 6:24 pm
by Me-no-dev
here are my "async" results (1MB file):
Code:
Code: Select all
  server.on("/download", HTTP_GET, [](AsyncWebServerRequest *request){
    AsyncWebServerResponse *response = request->beginResponse("text/plain", 1024 * 1024, [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
      memset(buffer, 'T', maxLen);
      return maxLen;
    });
    response->addHeader("Content-Disposition","attachment; filename=\"test_100k.txt\"");
    request->send(response);
  });



Wget Multi:
Code: Select allwget http://192.168.254.182/download & wget http://192.168.254.182/download & wget http://192.168.254.182/download & wget http://192.168.254.182/download
--2016-08-23 02:15:07--  http://192.168.254.182/download
--2016-08-23 02:15:07--  http://192.168.254.182/download
--2016-08-23 02:15:07--  http://192.168.254.182/download
--2016-08-23 02:15:07--  http://192.168.254.182/download
Connecting to 192.168.254.182:80... Connecting to 192.168.254.182:80... Connecting to 192.168.254.182:80... Connecting to 192.168.254.182:80... успешно свързване.
HTTP изпратено искане, чакам отговор... 200 OK
Дължина: 1048576 (1,0M) [text/plain]
Saving to: ‘download’

Дължина: 1048576 (1,0M) [text/plain]
Saving to: ‘download.1’

Дължина: 1048576 (1,0M) [text/plain]
Saving to: ‘download.2’

Дължина: 1048576 (1,0M) [text/plain]
Saving to: ‘download.3’

100%[========================================================================================================================================================================================================>] 1 048 576    527KB/s   in 1,9s   

2016-08-23 02:15:09 (527 KB/s) - ‘download’ saved [1048576/1048576]

100%[========================================================================================================================================================================================================>] 1 048 576    491KB/s   in 2,1s   

2016-08-23 02:15:10 (491 KB/s) - ‘download.2’ saved [1048576/1048576]

100%[========================================================================================================================================================================================================>] 1 048 576    528KB/s   in 1,9s   

2016-08-23 02:15:10 (528 KB/s) - ‘download.3’ saved [1048576/1048576]
100%[========================================================================================================================================================================================================>] 1 048 576    311KB/s   in 3,3s   

2016-08-23 02:15:11 (311 KB/s) - ‘download.1’ saved [1048576/1048576]


Wget one after another:
Code: Select all~/Downloads $ wget http://192.168.254.182/download; wget http://192.168.254.182/download; wget http://192.168.254.182/download; wget http://192.168.254.182/download
--2016-08-23 02:23:44--  http://192.168.254.182/download
Connecting to 192.168.254.182:80... успешно свързване.
HTTP изпратено искане, чакам отговор... 200 OK
Дължина: 1048576 (1,0M) [text/plain]
Saving to: ‘download.11’

100%[========================================================================================================================================================================================================>] 1 048 576    848KB/s   in 1,2s   

2016-08-23 02:23:45 (848 KB/s) - ‘download.11’ saved [1048576/1048576]

--2016-08-23 02:23:45--  http://192.168.254.182/download
Connecting to 192.168.254.182:80... успешно свързване.
HTTP изпратено искане, чакам отговор... 200 OK
Дължина: 1048576 (1,0M) [text/plain]
Saving to: ‘download.12’

100%[========================================================================================================================================================================================================>] 1 048 576    899KB/s   in 1,1s   

2016-08-23 02:23:47 (899 KB/s) - ‘download.12’ saved [1048576/1048576]

--2016-08-23 02:23:47--  http://192.168.254.182/download
Connecting to 192.168.254.182:80... успешно свързване.
HTTP изпратено искане, чакам отговор... 200 OK
Дължина: 1048576 (1,0M) [text/plain]
Saving to: ‘download.13’

100%[========================================================================================================================================================================================================>] 1 048 576    885KB/s   in 1,2s   

2016-08-23 02:23:48 (885 KB/s) - ‘download.13’ saved [1048576/1048576]

--2016-08-23 02:23:48--  http://192.168.254.182/download
Connecting to 192.168.254.182:80... успешно свързване.
HTTP изпратено искане, чакам отговор... 200 OK
Дължина: 1048576 (1,0M) [text/plain]
Saving to: ‘download.14’

100%[========================================================================================================================================================================================================>] 1 048 576    909KB/s   in 1,1s   

2016-08-23 02:23:49 (909 KB/s) - ‘download.14’ saved [1048576/1048576]