René's URL Explorer Experiment


Title: perf(webapp): cache task metadata in Redis for the trigger hotpath by ericallam · Pull Request #3625 · triggerdotdev/trigger.dev · GitHub

Open Graph Title: perf(webapp): cache task metadata in Redis for the trigger hotpath by ericallam · Pull Request #3625 · triggerdotdev/trigger.dev

X Title: perf(webapp): cache task metadata in Redis for the trigger hotpath by ericallam · Pull Request #3625 · triggerdotdev/trigger.dev

Description: Summary The trigger-task hotpath used to early-return without a DB query when a caller passed both a queue override and a per-trigger TTL — the hottest configuration on the trigger API. Adding triggerSource to the resolver so the runs-list "Source" filter could distinguish STANDARD / SCHEDULED / AGENT runs removed those early-returns, costing +2 DB queries per trigger on non-locked calls and +1 on locked calls. This change caches BackgroundWorkerTask metadata (ttl, triggerSource, queueId, queueName) in Redis so the resolver can satisfy every caller configuration with a single HGET on the warm path. PG fallback on miss back-fills the cache. Follow-up to #3542. Design Two key spaces: task-meta:env:{envId} — the "current worker" view, refreshed at every deploy promotion. 24h safety TTL. task-meta:by-worker:{workerId} — used for lockToVersion triggers. Immutable post-create. 30d sliding TTL so historical workers age out. Cache writes use Lua scripts via defineCommand so DEL + HSET + EXPIRE land atomically — concurrent readers never see the empty intermediate state of a naive pipeline. Read-path back-fill uses single-field upserts so concurrent back-fills don't wipe each other's siblings. The cache lives behind its own TASK_META_CACHE_REDIS_* env-var prefix that falls back to the default REDIS_* set, so operators can route the cache to a dedicated Redis instance if they want. The service/instance file split (taskMetadataCache.server.ts for the pure class, taskMetadataCacheInstance.server.ts for the env-wired singleton) mirrors the existing runsReplicationService / runsReplicationInstance pattern. Test plan pnpm run typecheck --filter webapp pnpm run test ./test/engine/triggerTask.test.ts --run — 8 existing tests untouched + 5 new tests covering warm cache, cold miss with back-fill, queue + ttl path, by-worker vs env keyspace, and the promotion cache write End-to-end against a dev worker: registering writes both keyspaces with the expected TTLs, and redis-cli HGETALL "tr:task-meta:env:" returns the cached entries Benchmark Measured DefaultQueueManager.resolveQueueProperties against a real Postgres + Redis (vitest containerTest, single-host docker). 500 sequential calls and 2,000 parallel calls (concurrency=50) per scenario, request shaped as { taskId, queue: "bench-queue", ttl: "5m" } — the hot path this PR restores. sequential (one in flight at a time): [noop cache (baseline)] n=500 mean=1.423ms p50=1.394ms p95=1.735ms p99=2.629ms max=11.100ms [redis cache, cold ] n=500 mean=1.346ms p50=1.283ms p95=1.688ms p99=2.463ms max=5.058ms [redis cache, warm ] n=500 mean=0.084ms p50=0.078ms p95=0.105ms p99=0.156ms max=1.129ms speedup (warm vs baseline, sequential): 16.95x parallel (concurrency=50): [noop cache (baseline)] n=2000 mean=10.069ms p50=8.850ms p95=14.718ms p99=31.887ms total=405ms ops/s=4,940 [redis cache, warm ] n=2000 mean=0.614ms p50=0.568ms p95=1.189ms p99=1.432ms total=25ms ops/s=80,389 throughput speedup (warm vs baseline, parallel): 16.27x Read: Warm cache cuts resolver latency 17× at p50 — from ~1.4 ms to ~78 µs per call. Cold cache is on par with baseline — the extra HGET miss adds <50 µs against the two Postgres queries that follow, so the worst case is not worse than today. Under burst load (50 concurrent triggers), the baseline's p99 jumps to ~32 ms as Postgres connections queue up; warm stays at ~1.4 ms. The cache moves the saturation point from ~5k ops/s (PG pool) to ~80k ops/s (single-client Redis pipelining). Caveats: single-host docker, local Postgres + Redis, resolver-only measurement (excludes the rest of the trigger transaction). Prod adds region-local Redis RTT (~0.3–0.8 ms) which shifts warm absolute numbers up but keeps the ratio intact.

Open Graph Description: Summary The trigger-task hotpath used to early-return without a DB query when a caller passed both a queue override and a per-trigger TTL — the hottest configuration on the trigger API. Adding trig...

X Description: Summary The trigger-task hotpath used to early-return without a DB query when a caller passed both a queue override and a per-trigger TTL — the hottest configuration on the trigger API. Adding trig...

Opengraph URL: https://github.com/triggerdotdev/trigger.dev/pull/3625

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:bd9cbbd4-1296-864c-b1af-66876a0d2db9
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE38E:37ACD:8AF343:CCFD4B:6AFAFEA8
html-safe-nonce9e117d9d8c2578acd2f6f58ce21fee01c361efa5b84d6967eab7b3ea212b71c9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzhFOjM3QUNEOjhBRjM0MzpDQ0ZENEI6NkFGQUZFQTgiLCJ2aXNpdG9yX2lkIjoiNTM1MDI4NzI5NDA5NzcxODk1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac686ed517a1f8a2e2e1fff4e6a7ac8173ff38f20c5b51159948cea21d381c078f
hovercard-subject-tagpull_request:3687570561
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/triggerdotdev/trigger.dev/pull/3625/files
twitter:imagehttps://avatars.githubusercontent.com/u/534?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/534?s=400&v=4
og:image:altSummary The trigger-task hotpath used to early-return without a DB query when a caller passed both a queue override and a per-trigger TTL — the hottest configuration on the trigger API. Adding trig...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None54f7a6886649661c85eee945cca0773566bfb4065370e0429b7c8f7204184650
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/triggerdotdev/trigger.dev git https://github.com/triggerdotdev/trigger.dev.git
octolytics-dimension-user_id95297378
octolytics-dimension-user_logintriggerdotdev
octolytics-dimension-repository_id572570113
octolytics-dimension-repository_nwotriggerdotdev/trigger.dev
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id572570113
octolytics-dimension-repository_network_root_nwotriggerdotdev/trigger.dev
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release3a69df62e401f1cbe8bd1ad791845bb4fc5b1c1d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/triggerdotdev/trigger.dev/pull/3625/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F3625%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Ftriggerdotdev%2Ftrigger.dev%2Fpull%2F3625%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=triggerdotdev%2Ftrigger.dev
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/3625/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/3625/files
Reloadhttps://github.com/triggerdotdev/trigger.dev/pull/3625/files
triggerdotdevhttps://github.com/triggerdotdev
trigger.devhttps://github.com/triggerdotdev/trigger.dev
Codehttps://github.com/triggerdotdev/trigger.dev
Issues203 (203)https://github.com/triggerdotdev/trigger.dev/issues
Pull requests67 (67)https://github.com/triggerdotdev/trigger.dev/pulls
Discussionshttps://github.com/triggerdotdev/trigger.dev/discussions
Actionshttps://github.com/triggerdotdev/trigger.dev/actions
Projectshttps://github.com/triggerdotdev/trigger.dev/projects
Security and quality39 (39)https://github.com/triggerdotdev/trigger.dev/security
Insightshttps://github.com/triggerdotdev/trigger.dev/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Ftriggerdotdev%2Ftrigger.dev%2Fissues%2Fnew%2Fchoose
ericallamhttps://github.com/ericallam
mainhttps://github.com/triggerdotdev/trigger.dev/tree/main
perf/trigger-task-cachehttps://github.com/triggerdotdev/trigger.dev/tree/perf/trigger-task-cache
Conversation 39 https://github.com/triggerdotdev/trigger.dev/pull/3625
Commits 7 https://github.com/triggerdotdev/trigger.dev/pull/3625/commits
Checks 31 https://github.com/triggerdotdev/trigger.dev/pull/3625/checks
Files changed https://github.com/triggerdotdev/trigger.dev/pull/3625/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3625/files
perf(webapp): cache task metadata in Redis for the trigger hotpath https://github.com/triggerdotdev/trigger.dev/pull/3625/files#top
Show all changes 7 commits https://github.com/triggerdotdev/trigger.dev/pull/3625/files
bdaaf06 perf(webapp): cache task metadata in Redis for the trigger hotpath ericallam May 15, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3625/commits/bdaaf060260d2710a8947a4d7ea3bce9868979ac
1a06ef6 fix(webapp): address CodeRabbit review on the task metadata cache ericallam May 15, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3625/commits/1a06ef6407d8af9d047e7029757632ef1ffb0451
344135a refactor(webapp): make task-metadata cache writes atomic per-call ericallam May 15, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3625/commits/344135a0b00d300530050e9b4dc819dc96ae8302
09a1a3b fix(webapp): reject locked triggers when the task is missing on that … ericallam May 15, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3625/commits/09a1a3b1df486b1e68344389b5a0e2a395f33b87
2c0fae2 fix(webapp): unblock CI on the task-metadata cache PR ericallam May 15, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3625/commits/2c0fae226d290e1f8ac18f17b2d54e9a88fd96c6
b9fc87b fix(webapp): close back-fill-vs-promotion race on env-keyspace cache … ericallam May 15, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3625/commits/b9fc87b0cffe6272199d6c4a229365084f9559c0
710df37 fix(webapp): tolerate missing task on locked + queue-override branch ericallam May 15, 2026 https://github.com/triggerdotdev/trigger.dev/pull/3625/commits/710df372e5db846e1360b17661b64631d55c917b
Clear filters https://github.com/triggerdotdev/trigger.dev/pull/3625/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3625/files
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3625/files
task-metadata-cache.md https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-b351d00965c08b97008c5d5103d5acf0011bb0f5bd20bb1b0e962b72b7aecc2b
env.server.ts https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-f8823615ef72da3494e74de9e62b2fa31315ed9360f17bc06ab943f4dc25f4fd
queues.server.ts https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-ca27db974fa06638842ca12ac46456105d2740f788ff6b76c8361baebe4e935a
taskMetadataCache.server.ts https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-964d3e28e240c3f568f8d46f65b381ce06a96b415fb03caa04c1c5ffdcff003f
taskMetadataCacheInstance.server.ts https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-b99259d7c47bd754fd4204e551868e15739dab9c57fbf34755109770d0135f6b
changeCurrentDeployment.server.ts https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-1cb07d10be838625e6b47e21d0f5186d22ec63c1421d2fd379fe48071eaa8310
createBackgroundWorker.server.ts https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-4f6cfdca149e5081bfdd486395d42c6d7e2a1d40a2bdf3e1c2e690d5c03b7efa
createDeploymentBackgroundWorkerV3.server.ts https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-17520d1d3559b2c451694532a210e9c7bfa048229c4225ceaac6471eaa4d02b8
createDeploymentBackgroundWorkerV4.server.ts https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-e4760e80a19838e2373e47e9275b2f7e5ebd0f73fb32db633f95012873defcb2
triggerTask.test.ts https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-32c8851ced7bd25bc9b7b45d1b4f52680ed437cf4bf0fce8a38e3669d07a2042
.server-changes/task-metadata-cache.mdhttps://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-b351d00965c08b97008c5d5103d5acf0011bb0f5bd20bb1b0e962b72b7aecc2b
View file https://github.com/triggerdotdev/trigger.dev/blob/710df372e5db846e1360b17661b64631d55c917b/.server-changes/task-metadata-cache.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3625/{{ revealButtonHref }}
apps/webapp/app/env.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-f8823615ef72da3494e74de9e62b2fa31315ed9360f17bc06ab943f4dc25f4fd
View file https://github.com/triggerdotdev/trigger.dev/blob/710df372e5db846e1360b17661b64631d55c917b/apps/webapp/app/env.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3625/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-f8823615ef72da3494e74de9e62b2fa31315ed9360f17bc06ab943f4dc25f4fd
https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-f8823615ef72da3494e74de9e62b2fa31315ed9360f17bc06ab943f4dc25f4fd
apps/webapp/app/runEngine/concerns/queues.server.tshttps://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-ca27db974fa06638842ca12ac46456105d2740f788ff6b76c8361baebe4e935a
View file https://github.com/triggerdotdev/trigger.dev/blob/710df372e5db846e1360b17661b64631d55c917b/apps/webapp/app/runEngine/concerns/queues.server.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/triggerdotdev/trigger.dev/pull/3625/{{ revealButtonHref }}
https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-ca27db974fa06638842ca12ac46456105d2740f788ff6b76c8361baebe4e935a
https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-ca27db974fa06638842ca12ac46456105d2740f788ff6b76c8361baebe4e935a
https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-ca27db974fa06638842ca12ac46456105d2740f788ff6b76c8361baebe4e935a
https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-ca27db974fa06638842ca12ac46456105d2740f788ff6b76c8361baebe4e935a
https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-ca27db974fa06638842ca12ac46456105d2740f788ff6b76c8361baebe4e935a
https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-ca27db974fa06638842ca12ac46456105d2740f788ff6b76c8361baebe4e935a
https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-ca27db974fa06638842ca12ac46456105d2740f788ff6b76c8361baebe4e935a
https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-ca27db974fa06638842ca12ac46456105d2740f788ff6b76c8361baebe4e935a
https://github.com/triggerdotdev/trigger.dev/pull/3625/files#diff-ca27db974fa06638842ca12ac46456105d2740f788ff6b76c8361baebe4e935a
Please reload this pagehttps://github.com/triggerdotdev/trigger.dev/pull/3625/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.