Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Please don't read too much into this. This is not a benchmark! This is a load test on a particular use case. If I were to use both for an ecommerce app, how would I do it? How fast is it?
---------------------------------------------------------------------------------------------------
Summary
---------------------------------------------------------------------------------------------------
(PL = pipelined redis operation)
Loading one million random names (full names) like John Smith, Patty Gerbee Sr)
MySQL: 06:05
Redis: 02:45
Redis C ext 01:32
Redis pipelined: 00:56
Redis pipelined C ext: 00:19
Ruby just loading array: 387ms
Loading 10k ecommerce-style data (orders, users, products)
MySQL: 00:09.40
Redis: 00:14.50
Redis PL: 00:02.72
---------------------------------------------------------------------------------------------------
1,000,000 names
MethodProfiler results for: MySQLLoader.load_names
+-------------------+---------------+---------------+---------------+---------------+-------------+
| Method | Min Time | Max Time | Average Time | Total Time | Total Calls |
+-------------------+---------------+---------------+---------------+---------------+-------------+
| #load_names | 361309.498 ms | 361309.498 ms | 361309.498 ms | 361309.498 ms | 1 |
| #delete_all_names | 4523.151 ms | 4523.151 ms | 4523.151 ms | 4523.151 ms | 1 |
| #initialize | 10.012 ms | 10.012 ms | 10.012 ms | 10.012 ms | 1 |
+-------------------+---------------+---------------+---------------+---------------+-------------+
6 minutes 05 seconds total (add up all total times)
10,000 users, 1,000 products, 10,000 x 3 random purchases max
MethodProfiler results for: MySQLLoader.load_sales
+-------------------+-------------+-------------+--------------+-------------+-------------+
| Method | Min Time | Max Time | Average Time | Total Time | Total Calls |
+-------------------+-------------+-------------+--------------+-------------+-------------+
| #load_orders | 5188.282 ms | 5188.282 ms | 5188.282 ms | 5188.282 ms | 1 |
| #load_users | 3739.058 ms | 3739.058 ms | 3739.058 ms | 3739.058 ms | 1 |
| #load_products | 357.639 ms | 357.639 ms | 357.639 ms | 357.639 ms | 1 |
| #delete_all_sales | 125.877 ms | 125.877 ms | 125.877 ms | 125.877 ms | 1 |
+-------------------+-------------+-------------+--------------+-------------+-------------+
9.4 seconds
1,000,000 names
MethodProfiler results for: RedisLoader
+-------------------+---------------+---------------+---------------+---------------+-------------+
| Method | Min Time | Max Time | Average Time | Total Time | Total Calls |
+-------------------+---------------+---------------+---------------+---------------+-------------+
| #load_names | 165101.731 ms | 165101.731 ms | 165101.731 ms | 165101.731 ms | 1 |
| #delete_all_names | 528.833 ms | 528.833 ms | 528.833 ms | 528.833 ms | 1 |
| #initialize | 0.068 ms | 0.068 ms | 0.068 ms | 0.068 ms | 1 |
+-------------------+---------------+---------------+---------------+---------------+-------------+
2 minutes 45 seconds
10,000 users, 1,000 products, 10,000 x 3 random purchases max
MethodProfiler results for: RedisLoader
+-------------------+--------------+--------------+--------------+--------------+-------------+
| Method | Min Time | Max Time | Average Time | Total Time | Total Calls |
+-------------------+--------------+--------------+--------------+--------------+-------------+
| #load_orders | 10211.381 ms | 10211.381 ms | 10211.381 ms | 10211.381 ms | 1 |
| #load_users | 3361.114 ms | 3361.114 ms | 3361.114 ms | 3361.114 ms | 1 |
| #delete_all_sales | 643.716 ms | 643.716 ms | 643.716 ms | 643.716 ms | 1 |
| #load_products | 315.040 ms | 315.040 ms | 315.040 ms | 315.040 ms | 1 |
| #initialize | 0.073 ms | 0.073 ms | 0.073 ms | 0.073 ms | 1 |
+-------------------+--------------+--------------+--------------+--------------+-------------+
14.5 seconds
--------------------+--------------+--------------+--------------+--------------+--------------
PIPELINED REDIS
(reduces network i/o, but sometimes you won't be able to pipeline, maybe you can't pre-queue)
--------------------+--------------+--------------+--------------+--------------+--------------
One Million Names into a List
+-------------------+--------------+--------------+--------------+--------------+-------------+
| Method | Min Time | Max Time | Average Time | Total Time | Total Calls |
+-------------------+--------------+--------------+--------------+--------------+-------------+
| #load_names | 55011.216 ms | 55011.216 ms | 55011.216 ms | 55011.216 ms | 1 |
| #delete_all_names | 526.902 ms | 526.902 ms | 526.902 ms | 526.902 ms | 1 |
| #initialize | 0.065 ms | 0.065 ms | 0.065 ms | 0.065 ms | 1 |
+-------------------+--------------+--------------+--------------+--------------+-------------+
Products push with made up ID (had to be ruby generated for it to work with pipeline)
+-------------------+-------------+-------------+--------------+-------------+-------------+
| Method | Min Time | Max Time | Average Time | Total Time | Total Calls |
+-------------------+-------------+-------------+--------------+-------------+-------------+
| #load_orders | 1557.347 ms | 1557.347 ms | 1557.347 ms | 1557.347 ms | 1 |
| #load_users | 716.847 ms | 716.847 ms | 716.847 ms | 716.847 ms | 1 |
| #delete_all_sales | 396.674 ms | 396.674 ms | 396.674 ms | 396.674 ms | 1 |
| #load_products | 56.369 ms | 56.369 ms | 56.369 ms | 56.369 ms | 1 |
| #initialize | 0.080 ms | 0.080 ms | 0.080 ms | 0.080 ms | 1 |
+-------------------+-------------+-------------+--------------+-------------+-------------+
2.72 seconds
For example the join table looked like this:
Orders Table
id | product_id | user_id
1 | 36 | 24
2 | 42 | 24
The id column is not really important in a join table. In this case, it was
generated using .each_with_index.
Using the hiredis gem (C extension, not portable to JRuby) with pipelined
One Million Names again.
+-------------+--------------+--------------+--------------+--------------+-------------+
| Method | Min Time | Max Time | Average Time | Total Time | Total Calls |
+-------------+--------------+--------------+--------------+--------------+-------------+
| #load_names | 19209.266 ms | 19209.266 ms | 19209.266 ms | 19209.266 ms | 1 |
| #initialize | 8.809 ms | 8.809 ms | 8.809 ms | 8.809 ms | 1 |
+-------------+--------------+--------------+--------------+--------------+-------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment