Turborepo · Job board · After reading the turborepo-jobs core source I finally understand the trade-offs

1.1K
TUr/turborepo-jobs·posted by ops_wang·2 days agoOpen source

After reading the turborepo-jobs core source I finally understand the trade-offs

Some background first. Our setup is turborepo-jobs plus three downstream services, seven figures of daily requests, peaking around nine in the evening.

// Minimal reproduction: you must use a real long-tail distribution here.
// Uniform load-test traffic will never trigger this.
func (s *Server) handle(ctx context.Context) error {
    conn, err := s.pool.Acquire(ctx)
    if err != nil {
        return fmt.Errorf("acquire: %w", err)
    }
    defer conn.Release()

    return s.do(ctx, conn)
}

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.

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 turborepo-jobs itself but our upstream connection reuse — the load test traffic was too clean and hid the long-tail requests.

Worth noting: the official docs do cover this, just in a very inconspicuous spot. I only found it reading the source comments, where the author explains the reasoning — roughly "so that it degrades into predictable behaviour in extreme cases".

170 comments

170 comments

· first 120 loaded
M
Zzhu_zongMod·2 days ago

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

515
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.

456
Nnikic·2 days ago

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

444
Rrase·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.

426
Hhuang_ke·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.

395
Nnikic·2 days ago

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

68
Nnikic·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.

317
Ddev_zhou·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.

314
Lli_ming·yesterday

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.

295
LlinlinMod·2 days ago

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

13
NnikicOP·2 days agoedited

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

231
Sswoole_leeOP·1 hour 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.

177
Cchen_dev·2 days 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.

29
Zzhu_zong·just now

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

234
Hhuang_ke·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.

216
Cchen_devOP·2 days 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.

137
Rrase·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.

30
Rran_boOP·2 days ago

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

133
Rran_bo·just now

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

17
Kkernel_panicOP·2 days ago

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

30
Oops_wangOP·2 days ago

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

79
Cchen_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.

360
Zzhu_zong·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.

5
Rran_bo·just nowedited

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.

190
Oops_wang·1 hour ago

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

226
Ddev_zhou·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.

78
Wwinter·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.

29
Oops_wang·2 days ago

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

190
Sswoole_lee·2 hours ago

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

169
Nnikic·2 days ago

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

165
Bbob_chenMod·2 days 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.

14
Kkite·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.

141
Cchen_dev·3 minutes agoedited

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.

138
Oops_wang·2 days ago

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

137
Nnikic·2 hours ago

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

129
Sswoole_leeOP·2 days agoedited

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

57
Cchen_dev·2 days ago

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

47
Rran_bo·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.

31
Aalice_dev·2 days ago

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

87
Sswoole_lee·28 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.

87
Aalice_devMod·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.

43
Rran_bo·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.

1
Zzhu_zong·2 days ago

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

1
Mmike_xu·2 days ago

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

349
Lli_mingOP·12 minutes ago

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

17
Bbob_chenOP·2 hours ago

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

8
Zzhu_zongOP·2 days ago

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

3
Oops_wang·2 days ago

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

58
Zzhu_zong·28 minutes ago

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

54
Kkite·2 days ago

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

505
Cchen_devOP·2 days ago

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

15
Zzhou_yi·2 hours 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.

54
Zzhu_zong·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.

31
Nnikic·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.

28
Lli_ming·2 days ago

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

25
Sslow_query·2 days ago

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

19
Lli_ming·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.

13
Llinlin·2 days 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.

9
Rrase·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.

9
Mmike_xu·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.

9
Bbob_chen·2 days ago

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

5
Rrase·2 hours ago

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

2
Lli_ming·12 minutes ago

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

1
Rran_bo·3 minutes ago

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

443
Cchen_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.

377
Lli_ming·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.

63
Oops_wang·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.

155
Rran_bo·2 days agoeditedLevel 6

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.

25
Aalice_devMod·2 days ago

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

151
Hhuang_ke·2 days agoLevel 6

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

373
Ttang_hao·2 days agoLevel 6

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.

100
Zzhou_yi·12 minutes agoLevel 6

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

2
Bbob_chenOP·2 days ago

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

3
Lli_ming·yesterday

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.

315
Kkite·12 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.

151
Lli_ming·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.

111
Sslow_query·2 days ago

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

275
Ttang_hao·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.

10
Llinlin·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.

28
Oops_wang·2 days agoLevel 6

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

191
Rrase·2 days ago

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

266
WwinterOP·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.

46
Oops_wang·2 days ago

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

264
Ddev_zhouOP·5 hours 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.

43
Rrase·2 hours 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.

314
Zzhu_zongOP·2 days ago

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

170
Lli_mingOP·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.

10
LlinlinOP·5 hours 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.

63
Cchen_dev·1 hour 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.

160
Kkite·3 minutes ago

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

247
Rrase·2 days ago

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

299
Zzhou_yi·28 minutes agoedited

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

193
Wwinter·2 days agoeditedLevel 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.

33
Lli_ming·2 days agoLevel 6

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.

1
Kkite·2 days agoedited

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

152
Bbob_chen·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.

101
Zzhou_yi·1 hour ago

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

420
Lli_ming·yesterdayLevel 6

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

113
Bbob_chen·2 days ago

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

9
Kkite·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.

86
Rrase·28 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.

447
Wwinter·2 days agoLevel 6

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

359
Rran_bo·2 days agoLevel 6

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

31
Cchen_dev·2 days agoeditedLevel 6

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

20
Kkite·2 days agoLevel 6

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

2
Llinlin·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
Hhuang_ke·3 minutes agoLevel 6

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

514
Aalice_dev·yesterdayLevel 6

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

37
Oops_wang·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.

13
Aalice_dev·2 days ago

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

128
Mmike_xuOP·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.

168
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.

30
Zzhou_yi·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.

85
Sslow_queryOPMod·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.

39
Bbob_chen·2 days ago

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

133
Ttang_hao·2 days ago

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

1
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.

1
Ttang_hao·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.

1
Ddev_zhou·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.

1
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.

1

This is the post detail page /en/c/turborepo-jobs/post/p11. 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 →