matomo-org / plugin-VisitorGenerator

Plugin to create fake visits, websites, users and goals to populate Matomo reports
https://matomo.org
GNU General Public License v3.0
19 stars 22 forks source link

Add direct database insertion option for fast visit generation #139

Closed bx80 closed 8 months ago

bx80 commented 8 months ago

Description:

This PR adds a new console command to the visitor generator which will directly insert fake visits into the database without using the tracker API.

This is intended for quickly creating large datasets where speed of data generation is more important than a perfect simulation of tracking requests.

Usage:

./console visitorgenerator:generate-visits-db [--idsite IDSITE] [--days DAYS] 
[--start-date START-DATE] 
[--limit-visits LIMIT-VISITS] 
[--limit-random-percent LIMIT-RANDOM-PERCENT] 
[--threads THREAD-COUNT]
[--conversion-percent CONVERSION-PERCENT]
[--min-actions MIN-ACTIONS]
[--max-actions MAX-ACTIONS]
[--actions-pool-size ACTIONS-POOL-SIZE]
[--v] [--vv] [--vvv]

Unoptimized performance on basic hardware is currently 350 - 700 visits per second (~2,500 insert/s) compared to ~7 visits per second for visits generated using the normal tracker API method.

vgdb-demo

Fixes #138

Review

bx80 commented 8 months ago

Added support for multiple threads using the Symphony\Process component, which this PR adds to the plugin composer dependencies. This is only used when the --threads=x option is used and will divide the daily limit by the number of specified threads, for example, if generating data for 3 days with a 1,000 visit limit per day and 4 threads, then each thread would simultaneously run for all three days but with a 250 limit per day. All multi-process input will be captured and displayed by the parent process along with a total summary of generated data.

michalkleiner commented 8 months ago

Nice work! There's somehow more to it than I envisaged 🙈 Had an initial look over the code and left a few questions, will try to run it locally as well.

AltamashShaikh commented 8 months ago

@bx80 Left comments on slack thread regarding warnings being received, when there is no goal also when there is 1 goal.

bx80 commented 8 months ago

Thanks for the review @AltamashShaikh :+1:

If there is no more review feedback, can someone in @matomo-org/plugin-reviewers merge this? (I don't have access).