|
| 1 | +version: 0.4 |
| 2 | +name: memtier_benchmark-session-caching-string-100k-sessions |
| 3 | +description: | |
| 4 | + Runs memtier_benchmark to simulate a session caching workload for a SaaS application. |
| 5 | + This benchmark focuses exclusively on **string-based session storage**, where each session |
| 6 | + is stored in Redis as a serialized JSON string (`session:<id>`) containing fields like |
| 7 | + user ID, timestamps, device info, and metadata (total ~400–600B). |
| 8 | +
|
| 9 | + The benchmark models a typical read-heavy cache usage pattern, with an approximate |
| 10 | + **read:write ratio of 80:20**, reflecting session retrievals and infrequent updates. |
| 11 | +
|
| 12 | + Command groups: |
| 13 | + - Session cache reads (`GET`): ~80% |
| 14 | + - Session cache writes (`SET`): ~20% |
| 15 | +
|
| 16 | + To better approximate real-world access patterns, the benchmark uses a **Zipfian key distribution** |
| 17 | + (`--command-key-pattern=Z`). This simulates **skewed access** where a small subset of sessions (hot keys) |
| 18 | + receives a majority of reads — a common pattern in production workloads. |
| 19 | +
|
| 20 | + While Zipfian is technically a power-law distribution, it effectively mimics **Poisson-like behavior** |
| 21 | + in large-scale systems, where access frequency is uneven but statistically predictable. |
| 22 | + This access skew mirrors real-life scenarios such as: |
| 23 | + - Frequently accessed or "sticky" user sessions |
| 24 | + - Popular user accounts or active devices |
| 25 | + - Hot caches for trending or recently used resources |
| 26 | +
|
| 27 | + Using Zipfian distribution allows this benchmark to capture **contention**, **cache pressure**, and |
| 28 | + **read amplification** effects that occur in real SaaS applications under load. |
| 29 | +
|
| 30 | +dbconfig: |
| 31 | + configuration-parameters: |
| 32 | + save: '""' |
| 33 | + resources: |
| 34 | + requests: |
| 35 | + memory: 1g |
| 36 | + init_lua: | |
| 37 | + local seed = 12345 |
| 38 | + math.randomseed(seed) |
| 39 | + local now = tonumber(redis.call('TIME')[1]) |
| 40 | + local function rand_str(len) |
| 41 | + local chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' |
| 42 | + local res = '' |
| 43 | + for i = 1, len do |
| 44 | + local idx = math.random(#chars) |
| 45 | + res = res .. chars:sub(idx, idx) |
| 46 | + end |
| 47 | + return res |
| 48 | + end |
| 49 | + for i = 1, 100000 do |
| 50 | + local session_id = 'session:' .. i |
| 51 | + local session_data = string.format( |
| 52 | + '{"userId":"user-%d","organizationId":"org-%d","role":"member","createdAt":"%d","lastAccessed":"%d","ipAddress":"192.168.1.%d","device":"device-%s","authMethod":"password","status":"active","metadata":"%s"}', |
| 53 | + i, i, now - math.random(3600), now, (i % 255), rand_str(8), rand_str(200 + (i % 100)) |
| 54 | + ) |
| 55 | + redis.call('SET', session_id, session_data) |
| 56 | + end |
| 57 | + return 'OK' |
| 58 | +
|
| 59 | +tested-groups: |
| 60 | +- string |
| 61 | + |
| 62 | +tested-commands: |
| 63 | +- get |
| 64 | +- set |
| 65 | + |
| 66 | +redis-topologies: |
| 67 | +- oss-standalone |
| 68 | + |
| 69 | +build-variants: |
| 70 | +- gcc:15.2.0-amd64-debian-bookworm-default |
| 71 | +- gcc:15.2.0-arm64-debian-bookworm-default |
| 72 | +- dockerhub |
| 73 | + |
| 74 | +clientconfig: |
| 75 | + run_image: redislabs/memtier_benchmark:edge |
| 76 | + tool: memtier_benchmark |
| 77 | + arguments: > |
| 78 | + --key-prefix "" |
| 79 | + --key-minimum 1 |
| 80 | + --key-maximum 100000 |
| 81 | + --data-size-range=400-600 |
| 82 | + --pipeline=1 |
| 83 | + --print-percentiles=50,90,95,99 |
| 84 | + --run-count=1 |
| 85 | + --test-time=120 |
| 86 | + --command="GET session:__key__" |
| 87 | + --command-key-pattern=Z |
| 88 | + --command-ratio=90 |
| 89 | + --command='SET session:__key__ "{\"userId\":\"user-__key__\",\"organizationId\":\"org-__key__\",\"role\":\"member\",\"createdAt\":\"1754905396\",\"lastAccessed\":\"1754906472\",\"ipAddress\":\"192.168.1.36\",\"device\":\"device-2T8YGLbl\",\"authMethod\":\"password\",\"status\":\"active\",\"metadata\":\"wDVmiQsSe2oSEPfhhvYN6jbVxVykSCzQXmnsqCIv5MEmpslD1LMgwJcUe8Wmhvhh56dgTDhH4o3M9vYa6JyAS3Axs2zufVVPWtTsCRVbNGjMmumy7j5vIM0OuclgbHBOxtGDtCU88YBc9IP5oNYiycXXCmq5s7mWAdmRhFrmFxOy3VKlrXJz4ZrtF6KHEflGhoF1FzXtLO8Dckg3B34kdxGsnNiRjNIEtWVxeXekUSDyrxcnwiIy29Zx8SxX2g8ZUrz3sTpEwX7KQZFpIi7XoSKZywvC6I63VMNpZcAO\"}"' |
| 90 | + --command-key-pattern=Z |
| 91 | + --command-ratio=10 |
| 92 | + --hide-histogram |
| 93 | + resources: |
| 94 | + requests: |
| 95 | + cpus: '4' |
| 96 | + memory: 2g |
| 97 | + |
| 98 | +priority: 150 |
0 commit comments