JoeDog / siege

Siege is an http load tester and benchmarking utility
GNU General Public License v3.0
5.9k stars 386 forks source link

fix: `--reps=once` behaves incorrectly with multiple concurrent connections #196

Closed midchildan closed 3 years ago

midchildan commented 3 years ago

When multiple concurrent connections are enabled, Siege with the --reps=once option will access the given URLs multiple times instead of just once as specified. This happens because Siege feeds the exact same set of URLs to every concurrent connection it creates. Since each benchmarking thread doesn't keep track of whether or not an URL has been accessed by any other threads, this results in the URLs being accessed more than once.

This change aims to correct this behavior so that --reps=once would work under all circumstances. It also fixes a few additional bugs that surfaced after fixing the original problem.

To explain the problem in more detail, the code that splits the URLs among individual connections exists, although it's currently not in use due to a regression in adc9b53. The remaining problems involve the logic for that part of the code:

  1. The regression also affected how the URLs are split. Instead of splitting the URLs evenly, it now assigns the nth connection an array of URLs that also includes all of the URLs for the (n-1)th connection.
  2. The splitting logic misses the last few URLs if the number of URLs aren't divided evenly by the number of concurrent connections. The amount of missed URLs are equal to the remainder of the division.