Load testing HTTP webserver



  • Hello
    I'm new with nodejs and microchip programming
    I'm trying to stress test the ESP32 Rover with HTML queries
    I have tested it using a simple auto refresh web page using dozens of browser tabs, its works without issues even after hundreds of thousands of concurrent requests, I just need to monitor memory use and manually call the GC when needed. But now id like to use a more robust tool, Apache Bench (ab)
    I'm using this command line
    ab -n 20 -c 1 http://192.168.7.126:81/ meaning 20 consecutive query to http://192.168.7.126:81/ (no concurrent query, -c 1)
    Now for some reasons, it hang at call number 12, everytime.... I get no error message and memory is fine. Do someone have any ideas/lead how to troubleshoot this, why is no error being caught ?

    Thanks

    Here the sample code

    var http = require('http');
    const low = require("lowsys");
    var os = require('os');

    connections = 0;

    var webport = process.env.PORT || 81;

    var server = http.createServer(function (req, res) {
    connections++;
    console.log("Connection count:"+connections);
    console.log("MEM:"+os.freemem());
    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.end('<HTML><head><meta http-equiv="refresh" content="2"><B style="color:red">Hello</B><HR>'+os.freemem()+'<HR>'+connections+'</HTML>');
    if (os.freemem()<1000000) {
    low.gc();
    }
    });

    server.on('error', function (e) {
    console.log(e);
    });

    process.on('uncaughtException', function( err ) {
    console.error(err.stack);
    });

    server.listen(webport);



  • Hello Louis,
    thank you for reporting this!
    Actually you are reporting 2 things at once: The failure of the stress test, and that you have to call gc(). Both should be fixed.
    Working on it, having some progress. Will write when there is a new version to try.
    Thomas



  • Thanks for your reply, I'll wait for your next release

    also, I'm not sure that
    server.maxConnections
    has any impact

    Thanks



  • server.maxConnections is not implemented.

    But, the stress test should work now! Can you flash the newest version and retry?

    Please note that reconnecting to IDE or calling lowsync does not work during the test. The reason for this is that ab uses all available sockets (even though it is concurrent, low.js is not fast enough to free the old sockets, they get freed as soon as the load is gone). So this is not a bug.

    Thomas



  • Hello
    Unfortunately, it hangs at try number 12 like before... (ab -n 20 http://192.168.7.124:81/)
    The LowJS version is 1.4.8, is that the latest ? I did a reflash
    lowsync --flash --port=com3 --init

    When it hangs, sometimes it comes back automatically after a few seconds sometimes I have to reset the MC to get control back. I'm browsing the forums, it might be related to the maximum simultaneous sockets that are available. That's why I was looking for a way to limit the number of connections.

    or maybe my dev board is of poor quality, I'll make sure to test the Neonious one when I get it..

    Thanks



  • Hello,
    yes, the problem that you cannot connect is the max no of sockets used as I wrote.
    Implementing server.maxConnections is a second step to make that lowsync/IDE is still working, for now I want to make sure that ab does not hang.
    It worked till 1500 connections (did not try more) yesterday with the debug version, will check in the next few days with the release version to see where the difference is.
    Thomas



  • I finally had time to test.
    Here it is working well in the release version, too...

    Here I called ab and after a while stopped via Ctrl-C. low.js seems to do requests well.

    Thomass-MacBook-Pro:test t.rogg$  ab -n 1000 -c 1 http://192.168.0.1:81/
    This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
    Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
    Licensed to The Apache Software Foundation, http://www.apache.org/
    
    Benchmarking 192.168.0.1 (be patient)
    ^C
    
    Server Software:        
    Server Hostname:        192.168.0.1
    Server Port:            81
    
    Document Path:          /
    Document Length:        104 bytes
    
    Concurrency Level:      1
    Time taken for tests:   17.982 seconds
    Complete requests:      65
    Failed requests:        1
       (Connect: 0, Receive: 0, Length: 1, Exceptions: 0)
    Total transferred:      10854 bytes
    HTML transferred:       6759 bytes
    Requests per second:    3.61 [#/sec] (mean)
    Time per request:       276.641 [ms] (mean)
    Time per request:       276.641 [ms] (mean, across all concurrent requests)
    Transfer rate:          0.59 [Kbytes/sec] received
    
    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        2    4   2.9      3      24
    Processing:   156  272 134.5    205     811
    Waiting:      125  235 132.7    171     783
    Total:        158  276 134.7    208     813
    
    Percentage of the requests served within a certain time (ms)
      50%    207
      66%    228
      75%    369
      80%    393
      90%    446
      95%    465
      98%    633
      99%    813
     100%    813 (longest request)
    Thomass-MacBook-Pro:test t.rogg$
    

    So what is different with your setup? Windows maybe? Or did the reflash maybe not really happen?



  • Hello
    Since I updated the firmware, I do see a major improvement, I'm now able to run around 80 requests without crashing every time, at n=100 works every two times. When it crashes, I have to restart the MC.

    Now, I'm looking at your output above, and the result only shows 65 completed requests out of 1000, try leaving it run to completion, it will either complete or timeout....

    thanks for your help



  • The next version is a bigger one which includes a new file system (LittleFS instead of SPIFFS, 8x speed with files). Because of testing, I believe it will be online earliest on Tuesday. It will hopefully include the fix.



  • The new version is online! Do you want to try it out?


Log in to reply