Commit 00ea494
authored
docs(billing/crons): jitter & sharding guidance (#3579)
* docs(billing/crons): add jitter & sharding guidance to README
* docs(billing/crons): fix jitter & sharding guidance accuracy
- Remove misleading "persisted across restarts" prose — K8s CronJob scripts
are invoked once per execution, so jitter is naturally per-invocation
- Replace cron.schedule() snippet (no-cron-dep model) with a self-executing
top-level await delay pattern matching the actual entrypoint structure
- Add optional stable per-pod jitter derivation from HOSTNAME hash
- Add SHARD_INDEX/SHARD_TOTAL env-var example in CronJob manifest + script
filter snippet to complete sharding implementation guidance
* docs(billing/crons): replace $where shard filter with safe client-side hash
$where executes JS in MongoDB and is deprecated/disabled in newer versions.
Replace with a client-side hash on _id strings — same O(n) complexity, no
server-side JS dependency.
* docs(billing/crons): fix CJS compatibility + variable shadowing + scalability note
- Wrap jitter snippet in async IIFE (CJS entrypoints don't support top-level await)
- Rename stable-jitter variables (hostHash/stableJitterMs) to avoid const redeclaration
if both snippets appear in the same file
- Add scalability caveat on in-memory shard filter; point toward server-side $mod for
high tenant counts1 parent 3b5aada commit 00ea494
1 file changed
Lines changed: 63 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
56 | 119 | | |
57 | 120 | | |
58 | 121 | | |
0 commit comments