iNem0o / expiration-queue-benchmark

This benchmark aim to test the performance of **Redis 7.0** vs **MariaDB 10.10** executing the tasks to manage and maintain a large dataset of items associated with a validity timestamp.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expiration Queue Management benchmark

This benchmark aim to test the performance of Redis 7.0 vs MariaDB 10.10 executing the tasks to manage and maintain a large dataset of items associated with a validity timestamp.

The main specification is defined using the Bench interface providing the mandatory methods corresponding to the expected benchmark algorithm.

Expected features :

  • ๐Ÿš€ Queue length must be equal to 10 000 000 items
  • ๐Ÿ” Each item must be selectable and updatable using a unique text identifier
  • ๐Ÿ”จ It must be possible to select expired items in batch of N items
  • ๐Ÿ’พ Each item must have associated metadata used to help expired item handling (ex : reindaxion priority management using business rules) stored as string

The Bench->cleanup() and Bench->getDatasetSizeInMegabytes() methods are dedicated to the benchmark report and replay features.

MariaDB overview

Associated code : BenchMariaDB.php

MariaDB benchmark use a SQL table with the following 3 columns :

CREATE TABLE `indexer` (
  `identifier` varchar(50) NOT NULL,
  `expiration_timestamp` int(11) NOT NULL,
  `metadata` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`identifier`),
  KEY `indexer_expiration_timestamp` (`expiration_timestamp` ASC)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Basic algorithm :

BenchMariaDB->addItem()

  • INSERT INTO the indexer table

BenchMariaDB->batchExpired()

  • fetch N items with timestamp < now (SELECT using expiration_timestamp index )
  • fetch and iterate over the items
  • update each item's timestamp and metadata one by one (update using PK identifier)

Redis overview

Associated code : BenchRedis.php

Redis implementation use a combination of a Sorted Set (collection of unique members ordered by an associated score) to manage the timestamps and a key value pair to store each item metadata.

BenchRedis->addItem()

  • add item to the sorted set using zAdd and timestamp as score
  • add item metadata to the associated key generated using identifier

BenchRedis->batchExpired()

  • fetch N items with timestamp < now (using zRangeByScore)
  • fetch and iterate over the items
    • grab each item metadata using get
    • update each item's timestamp one by one using zAdd and timestamp as score
    • update each item's metadata one by one using set

Results

You can download the following report data :

The following pictures are available in the full PDF report

config.jpg insert.png batch_during_insert.png batch_all_expired.png

About

This benchmark aim to test the performance of **Redis 7.0** vs **MariaDB 10.10** executing the tasks to manage and maintain a large dataset of items associated with a validity timestamp.

License:MIT License


Languages

Language:PHP 91.8%Language:Shell 5.6%Language:Dockerfile 2.6%