jeffbski / bench-rest

bench-rest - benchmark REST (HTTP/HTTPS) API's. node.js client module for easy load testing / benchmarking REST API's using a simple structure/DSL can create REST flows with setup and teardown and returns (measured) metrics.
MIT License
303 stars 51 forks source link

bench-rest not able to run second bench-marking in same nodejs process #1

Closed thomasmodeneis closed 10 years ago

thomasmodeneis commented 10 years ago

I'm running bench-rest as web-app together with express and I found a problem when trying to run the bench-rest more than once I see the nodejs process never kicks in again, so probably something is hanging after the process is finished ? is there a way to ensure gc or release the threads ?

Thanks

This is the code im running:

app.get('/benchtest', function(req, res) { console.log('running benchmark test for site:'); console.log('site: '+req.query.site); console.log('limit: '+req.query.limit); console.log('iterations: '+req.query.iterations); console.log('prealloc: '+req.query.prealloc); var benchrest = require('bench-rest');

          var flow = {
            before: [],      // operations to do before anything
            beforeMain: [],  // operations to do before each iteration
            main: [  // the main flow for each iteration, #{INDEX} is unique iteration counter token

// { put: 'http://localhost:8000/foo_#{INDEX}', json: 'mydata_#{INDEX}' }, { get: req.query.site } ], afterMain: [], // operations to do after each iteration after: [] // operations to do after everything is done }; var runOptions = { progress: 1000,
limit: req.query.limit, // concurrent connections iterations: req.query.iterations, // number of iterations to perform // prealloc: req.query.prealloc // only preallocate up to 100 before starting }; var errors = []; benchrest(flow, runOptions) .on('error', function (err, ctxName) { console.error('Failed in %s with err: ', ctxName, err); })

            .on('progress', function (stats, percent, concurrent, ips) {
              console.log('Progress: %s complete', percent);
              if(percent==0){
                  errors.push(percent);
              }
              if(errors.length > 10){
                  res.send({result: {stats: null, errorCount:1}});
              }
            })

            .on('end', function (stats, errorCount) {
              console.log('error count: ', errorCount);
              console.log('stats', stats);
              res.send({result: {stats: stats, errorCount:errorCount}});
            });

    });

this is the logs:

Progress: 0 complete Progress: 60 complete error count: 0 stats { totalElapsed: 238068, main: { meter: { mean: 3.3783783783783785, count: 5, currentRate: 2.785515320334262, '1MinuteRate': 0, '5MinuteRate': 0, '15MinuteRate': 0 }, histogram: { min: 236587, max: 238068, sum: 1185539, variance: 473156.20000000537, mean: 237107.8, stddev: 687.8635039017591, count: 5, median: 236636, p75: 237840, p95: 238068, p99: 238068, p999: 238068 } } } running benchmark test for site: site: http://google.com limit: 1 iterations: 1 prealloc: 1 Progress: 0 complete Progress: 0 complete error count: 0 stats { totalElapsed: 2274, main: { meter: { mean: 1000, count: 1, currentRate: 1000, '1MinuteRate': 0, '5MinuteRate': 0, '15MinuteRate': 0 }, histogram: { min: 2274, max: 2274, sum: 2274, variance: null, mean: 2274, stddev: 0, count: 1, median: 2274, p75: 2274, p95: 2274, p99: 2274, p999: 2274 } } } running benchmark test for site: site: http://google.com limit: 1 iterations: 1 prealloc: 1 Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete Progress: 0 complete

jeffbski commented 10 years ago

My test runs multiple runs against the same server, so there shouldn't be anything wrong with what you are trying to do (ie. bench-rest should support that just fine).

Unfortunately the code you pasted in didn't format right, so I am having trouble completely seeing what you are doing or where the error might be.

You can surround your code snippet with a new line with three back ticks before and after the code and it shouldn't mess with the formatting.

Alternatively you can create a gist and provide a link.

That way I can take a look and see if I can find the issue.

thomasmodeneis commented 10 years ago

Hi Jeff, To help I created an app on github so you can just clone it and try the POC couple times till you see the reported behavior, lets see if we can find what is going on!

https://github.com/thomasmodeneis/bench-rest-webapp-poc

Thanks

jeffbski commented 10 years ago

Thomas, thanks I will pull it down and see if I can help debug it.

thomasmodeneis commented 10 years ago

Hi Jeff, I solved it temporarily with child_spawn and commited it to the github repos, the problem now is that after few testings the app runs out of memory and becomes completely un-responsive. Well you can check that out later if you have time!

Thanks

On Wed, Dec 11, 2013 at 1:40 PM, Jeff Barczewski notifications@github.comwrote:

Thomas, thanks I will pull it down and see if I can help debug it.

— Reply to this email directly or view it on GitHubhttps://github.com/jeffbski/bench-rest/issues/1#issuecomment-30317044 .

jeffbski commented 10 years ago

Thomas,

Yes, I will take a look and see if I can figure out what is going on. I didn't see anything obvious in my first look but will give it a closer look soon.

Jeff

jeffbski commented 10 years ago

Thomas,

Well you aren't going to believe this.

I cloned the repo you mentioned and checkout commit bc9f8f7 (the one before you started using spawn) and for me it is working just fine.

I can make as many requests as I want and it responds beautifully, no issues that I could see.

I just pointed it at sites codewinds.com and google.com and didn't have any issues.

I am running on a mac OSX 10.8.5 with node.js version 0.10.23

I'm not sure what to look at next since it is working over here. Let me know what OS and node.js version you are running.

Jeff

jeffbski commented 10 years ago

I am going to close this for now since it appears to be working. We can reopen if there is new info later.