Redis · Ops · Cut our redis-ops build from 4 minutes to 40 seconds with these 5 changes

1.3K
REr/redis-ops·posted by winter·32 minutes agoExperience

Cut our redis-ops build from 4 minutes to 40 seconds with these 5 changes

It took me two weeks of on-and-off digging and plenty of wrong turns. Writing the process down as it happened so the next person spends less time.

One last trap: in container environments remember to adjust the memory-related parameters in step. Otherwise the host limit and the process expectation disagree, and the symptom is intermittent, unreproducible failure.

-- The query that broke: a full scan over 20M rows.
-- A composite index took P99 from 1.8s down to 42ms.
SELECT id, title, created_at
  FROM posts
 WHERE community_id = ?
   AND status = 1
 ORDER BY score DESC
 LIMIT 20;

What genuinely surprised me was the tail. The average looked great while P99 jumped by an order of magnitude past some threshold. The cause was not redis-ops itself but our upstream connection reuse — the load test traffic was too clean and hid the long-tail requests.

On trade-offs, my view is this: if nobody on the team owns this area long-term, do not introduce a second mechanism. With two coexistence you first have to work out which one is even in play when things break, and that costs far more than the performance you saved.

377 comments

377 comments

· first 120 loaded
M
Zzhou_yiOP·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

513
Sswoole_lee·28 minutes ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

497
Bbob_chen·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

452
Llinlin·12 minutes ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

151
Hhuang_ke·2 days ago

I just read the redis-ops source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

73
Cchen_devMod·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

14
Zzhu_zong·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

54
Ttang_hao·1 hour ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

35
Oops_wang·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

7
Nnikic·28 minutes ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

143
Rrase·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

290
Zzhou_yiOP·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

329
Ddev_zhou·2 days ago

This is not a redis-ops problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

257
Llinlin·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

161
Ddev_zhouMod·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

471
Kkite·5 hours agoedited

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

247
Rrase·2 days agoedited

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

502
Rran_bo·yesterday

One counter-example: below redis-ops 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

123
Aalice_dev·2 days agoLevel 6

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

60
Zzhou_yi·2 days agoedited

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

38
Llinlin·2 days agoLevel 6

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

309
Bbob_chen·2 days agoLevel 6

I just read the redis-ops source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

10
Sswoole_lee·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

35
Llinlin·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

5
Ddev_zhou·2 days ago

I just read the redis-ops source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

4
Oops_wang·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

7
Zzhou_yi·2 days ago

This is not a redis-ops problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

487
Sslow_query·12 minutes agoedited

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

446
Mmike_xu·yesterday

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

1
Ttang_hao·2 days agoedited

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

36
Rran_bo·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

266
Kkite·28 minutes ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

42
Cchen_dev·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

7
Hhuang_ke·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

427
Zzhou_yiOP·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

483
Kkite·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

420
Sslow_query·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

410
Ttang_haoOP·5 hours ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

346
Zzhou_yi·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

372
NnikicOPMod·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

137
Mmike_xu·3 minutes ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

345
Zzhou_yi·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

115
Nnikic·2 hours agoedited

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

3
Sswoole_lee·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

478
RraseOP·2 hours ago

I just read the redis-ops source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

248
Mmike_xuOP·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

432
Rrase·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

304
Cchen_dev·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

195
Cchen_dev·2 hours ago

This is not a redis-ops problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

297
Sslow_query·5 hours ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

224
Zzhu_zong·just now

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

95
Wwinter·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

15
Kkite·28 minutes ago

This is not a redis-ops problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

276
Nnikic·2 days agoedited

One counter-example: below redis-ops 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

3
Mmike_xuOP·2 days agoedited

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

221
Zzhou_yi·2 days agoedited

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

274
Sswoole_lee·3 minutes ago

This is not a redis-ops problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

268
Aalice_dev·3 minutes ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

249
Sswoole_lee·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

219
Zzhu_zong·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

209
Sslow_query·2 days ago

One counter-example: below redis-ops 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

162
Sswoole_lee·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

153
Mmike_xu·3 minutes ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

145
Ddev_zhou·yesterday

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

230
Llinlin·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

37
Kkite·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

21
Ddev_zhou·2 days ago

Agreeing with the above. One addition: with this option enabled the GC count in your metrics doubles, so adjust the alert threshold at the same time or it will keep firing.

12
Zzhou_yi·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

5
Rran_bo·just now

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

236
Wwinter·2 days ago

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

267
Lli_ming·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

53
Cchen_dev·2 days ago

One counter-example: below redis-ops 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

26
Ttang_hao·yesterday

I see point 3 differently. The trade-off depends on your read/write ratio: read-heavy with little writing means caching actually widens the inconsistency window.

10
Aalice_dev·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

216
Hhuang_ke·2 days ago

I just read the redis-ops source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

112
Kkernel_panic·2 days ago

I just read the redis-ops source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

41
Sswoole_lee·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

1
Zzhu_zong·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

431
Wwinter·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

90
Llinlin·2 days ago

This is not a redis-ops problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

4
Sswoole_lee·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

138
Nnikic·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

380
Aalice_dev·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

117
Cchen_dev·3 minutes ago

One counter-example: below redis-ops 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

106
Sswoole_lee·2 days agoedited

This is not a redis-ops problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

183
Llinlin·2 days ago

One counter-example: below redis-ops 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

92
Zzhou_yi·5 hours ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

88
Ddev_zhou·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

78
Zzhou_yiOPMod·3 minutes agoedited

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

15
Lli_ming·3 minutes ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

66
Lli_ming·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

65
Ttang_hao·2 days agoedited

I just read the redis-ops source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

53
Aalice_dev·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

39
Cchen_dev·just now

One counter-example: below redis-ops 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

32
Zzhou_yi·2 days ago

This is not a redis-ops problem, it is a usage problem. The docs say this API is not thread-safe and you must lock around it yourself.

30
Mmike_xu·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

26
Zzhou_yiOP·2 days ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

510
Oops_wangOP·2 days ago

Saved. I am reworking this area this week — this saves a lot of wrong turns.

66
Mmike_xu·yesterday

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

117
Kkernel_panicMod·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

1
Wwinter·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

328
Zzhu_zong·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

19
Kkernel_panic·2 days agoedited

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

13
Cchen_dev·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

10
Aalice_dev·2 hours ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

9
Rrase·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

2
Sswoole_lee·2 days ago

A question: what changes in a container with a 512Mi memory limit? That is how we run it in production.

24
Rrase·3 minutes ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

3
Ttang_haoMod·2 days ago

This matches what we see in production. We only hit it past 3k QPS; the earlier load tests showed nothing — the test traffic was too clean, with no long-tail requests.

3
Bbob_chen·2 days ago

We have run this in production for two years without hitting it. That said, we never reached this scale, so our experience is not really evidence here.

3
Kkernel_panic·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

2
Bbob_chen·1 hour ago

Has anyone run a controlled experiment? I did, reducing it to a single variable, and the difference was 4% — within noise. So I suspect the main cause is something else.

2
Zzhu_zong·just now

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

1
Cchen_dev·3 minutes agoedited

I just read the redis-ops source — the author actually explains the reasoning in a comment, roughly "so that it degrades into predictable behaviour in extreme cases".

105
Nnikic·2 days ago

There is actually a simpler fix that needs no architecture change: move this check up to the gateway and the problem disappears. The cost is one extra lookup at the gateway.

6
Zzhou_yi·2 days ago

Worth learning from this debugging approach. We went straight at the logs and took a much longer route.

497
Cchen_devOP·2 days ago

Sharing our numbers, 8 cores 16GB, same scenario:

| Concurrency | P50 | P99 |
|---|---|---|
| 200 | 12ms | 88ms |
| 500 | 31ms | 340ms |

P99 clearly collapses at 500 concurrency, which lines up with your knee point.

405
Ddev_zhou·2 days ago

Thanks for sharing real numbers — far more useful than the articles that only cover concepts.

422
Oops_wangMod·2 days ago

One counter-example: below redis-ops 7.4 the semantics of that code are different, so do not copy it verbatim. We got burned in staging and rolled back once.

1
Rran_bo·2 days ago

Can you give a minimal reproduction? I ran it locally for ten minutes and could not reproduce on macOS with the latest version.

1

This is the post detail page /en/c/redis-ops/post/p2. Posts and comments are generated deterministically from a seeded PRNG, so the same post always renders the same content and the link can be shared, reloaded and indexed. In production this page reads MySQL for the post, Redis for hot-post caching, and fetches the whole comment tree in a single query on the path column.

See the database schema →