Repository navigation
[Feature Request] Session support #12231
Replies: 6 comments
|
Here's an alternative: https://github.com/temporalio/samples-typescript/tree/main/activities-sticky-queues If anyone has a use case in which this doesn't work well, please post a comment, thanks! |
|
Note that the main difference between sticky activities and sessions is concurrency control, max concurrent sessions vs to max concurrent activities per worker. |
|
I took a look at the sticky queue but it's not clear that it matches exactly what I need. In particular, I have two doubts/questions:
|
|
Sorry for the late response.
A worker only listens on a single task queue but you can start multiple workers in the same process.
You'll need to use schedule to start timeout to detect that the worker went away and restart the sequence of activities. |
|
This appears to have been transferred from the TypeScript SDK issue tracker, but for those wondering, all SDKs support a concept of "worker-specific task queues" which basically provides session behavior. |
Response: Worker-Specific Task Queue Pattern ImplementationThank you for the detailed response and for tracking this in #12230. I appreciate the context about the redesign requirements and the challenges with the current Go Sessions implementation. I'd like to share our architectural approach to the Worker-Specific Task Queue pattern, addressing the points you raised, as it might provide valuable insights for the Sessions redesign. Our Architecture OverviewTwo-Task-Queue DesignWe operate with two separate task queues:
This separation ensures that schedule triggers don't interfere with ETL execution, and each worker has its own dedicated queue for ETL workflows. Sequential Execution ModelOur ETL workflows are sequential by design - activities execute one after another, not in parallel. Therefore:
Key Point: The critical mechanism for our use case is Addressing Your Points1. "It is possible to achieve almost the same behavior with the Worker Specific Task Queue pattern, but it is quite daring to properly implement by users"Our Architectural Approach: We've implemented a database-backed worker registration and load balancing system that addresses the "daring" aspects: Worker Registration Layer:
Centralized Load Balancer:
Why This Architecture:
2. "User-land implementations have limited ability for controlling execution concurrency at the worker level"Our Concurrency Control: Since our workflows are sequential, we set:
The Critical Mechanism:
Why This Matters:
3. "Things have significantly improved with Custom Slot Providers and Poller Behaviors"We haven't explored Custom Slot Providers and Poller Behaviors because they address a different concern than our use case. These features improve concurrency control and polling efficiency within a single worker instance, while our challenge is:
For our specific use case (workflow-level distribution and affinity), our implementation using worker-specific task queues addresses these requirements effectively. 4. "The current design can't offer the kind of DX and operational guarantees that Temporal users expect, notably when it comes to error-handling scenarios"Error Handling Challenges We've Encountered: Our implementation revealed several critical error-handling complexities: Challenge 1: Concurrent Schedule Triggers and Load BalancingProblem: When multiple schedules trigger simultaneously (e.g., multiple ETL schedules fire at the same time), we need to ensure:
Our Solution - Two-Level Serialization:
Why Both Levels:
Challenge 2: Tracking Workflow Completion and CleanupProblem: When a workflow completes (successfully or with failure), we need to:
Our Solution - Periodic Cleanup: Each worker runs a periodic cleanup process (every heartbeat interval, default 30 seconds) that:
Challenges:
Challenge 3: Worker Health Monitoring (Heartbeat)Problem: We need to detect when a worker dies or becomes unresponsive, so we can:
Our Solution - Heartbeat Mechanism:
Challenges:
Use Case: File Download and Sequential ProcessingScenario: Our ETL workflows download large files (often several GB) from vendor APIs and process them sequentially in chunks. Workflow Pattern:
Why Sticky Execution is Critical:
How Our Architecture Addresses This:
Architecture Components1. Worker Registration Service
2. Heartbeat Service
3. Workflow Balancer Service
4. Database Schema
Data FlowWhat We've LearnedWhat Works Well:
Pain Points:
Thank you for considering this feedback @mjameswh, and I look forward to contributing to the discussion. |
Uh oh!
There was an error while loading. Please reload this page.
Would be great if Sessions similar to the Go SDK were supported in TS as well.
All reactions