autocannon icon indicating copy to clipboard operation
autocannon copied to clipboard

Requests (from options) are repeated when overallRate>1 - should be configurable

Open md-fid opened this issue 4 years ago • 2 comments

Description

When configuring autocannon to run with a specific rate (rate or requests/secs) and also have a set of "prepared" requests given with "requests" option, then these requests are repeated. This is okay when running GET (reading) requests. But for other HTTP methods this could cause error like "409 conflict".

We have a scenario where we have a flat file of numbers. This file is used to prepare an Array of POST/PUT requests with specific paths including these numbers. When we then run autocannon for benchmarking, we retrieve a high number of errors in responses with "409 Conflict" because on server side the number from the the request path is unique.

Possible solution

It should be configurable that the num of rates (overallRate) should not repeat the one request from the Array but take the next one.

md-fid avatar Mar 19 '20 08:03 md-fid

Would you like to send a PR to implement this functionality?

mcollina avatar Mar 19 '20 08:03 mcollina

@md-fid @mcollina I tried to reproduce the issue in my local environment and I could not generate the issue you presented. I create 5 requests:

{
    url: path,
    connections: 1,
    overallRate: 5,
    amount: 5,
    requests: [
      {
        method: 'GET',
        path: '/users/1',
        onResponse (status, body) {
        }
      },
      {
        method: 'GET',
        path: '/users/2',
        onResponse (status, body) {
        }
      },
      {
        method: 'GET',
        path: '/users/3',
        onResponse (status, body) {
        }
      },
      {
        method: 'GET',
        path: '/users/4',
        onResponse (status, body) {
        }
      },
      {
        method: 'GET',
        path: '/users/5',
        onResponse (status, body) {
        }
      }
    ]
  }

So basically when you limit the amount to 5 and the autocannon will not repeat over the requests that already have been called.

Is it a good enough solution? 'cause otherwise I could not really understand the issue you're facing nor the solution.

EladIsraeli avatar May 05 '21 14:05 EladIsraeli