Frontend Service
The Frontend Service is the entry point for all external communication with the Temporal cluster. It acts as an API gateway, handling request validation, rate limiting, and routing to appropriate internal services.Overview
The Frontend Service exposes three main gRPC APIs:- Workflow Service API: Primary API for workflow operations (start, signal, query, etc.)
- Operator Service API: Cluster operations and maintenance (add search attributes, etc.)
- Admin Service API: Advanced administrative operations (workflow reset, shard management)
Core Responsibilities
API Gateway
The Frontend Service acts as the single entry point for all external requests:- Protocol Translation: Converts external gRPC requests to internal service calls
- Request Routing: Directs requests to the appropriate History or Matching Service instance
- Response Aggregation: Collects responses from internal services and returns to clients
Request Validation
Before forwarding requests, the Frontend validates:Namespace Validation
Namespace Validation
- Verifies namespace exists and is active
- Checks namespace state (registered, deprecated, deleted)
- For global namespaces, checks if cluster is active
Payload Size Limits
Payload Size Limits
- Workflow input payload size
- Activity input payload size
- Memo and search attribute sizes
- Configurable via dynamic config
ID Length Limits
ID Length Limits
- Workflow ID length
- Activity ID length
- Task queue name length
- Prevents database key length issues
API-Specific Validation
API-Specific Validation
- Required fields are present
- Enum values are valid
- Timeout values are reasonable
- Retry policies are valid
Rate Limiting
The Frontend Service enforces multiple layers of rate limiting:Global Rate Limits
- Global RPS: Total requests per second across all namespaces
- Operator RPS: Separate limit for operator APIs
- Protects the cluster from overload
Namespace Rate Limits
- Per-Namespace RPS: Requests per second per namespace
- Visibility RPS: Separate limit for list/scan operations
- Long-Running Request Concurrency: Limits concurrent long-poll requests
Per-API Rate Limits
Some APIs have specialized rate limits:- Namespace replication-inducing APIs (create, update, delete namespace)
- Worker versioning APIs (build ID operations)
- Batch operations
Request Routing
The Frontend routes requests to the correct service instance:History Service Routing
For workflow operations:- Calculate shard ID from workflow ID (consistent hashing)
- Look up History Service instance owning that shard
- Forward request via gRPC to that instance
Matching Service Routing
For task queue operations:- Hash task queue name to determine partition
- Look up Matching Service instance owning that partition
- Forward request via gRPC to that instance
Namespace-Based Routing
For multi-cluster setups:- Check if namespace is active in current cluster
- If not, optionally forward to active cluster
- Controlled by
EnableNamespaceNotActiveAutoForwardingconfig
Health Checking
The Frontend provides gRPC health check endpoints:- Standard gRPC health check protocol
- Returns
SERVINGwhen all dependencies are healthy - Returns
NOT_SERVINGduring shutdown or degraded state
API Handlers
Workflow Service API
The primary API for workflow operations: Workflow Lifecycle:StartWorkflowExecutionSignalWorkflowExecutionSignalWithStartWorkflowExecutionRequestCancelWorkflowExecutionTerminateWorkflowExecution
QueryWorkflowExecutionUpdateWorkflowExecutionPollWorkflowExecutionUpdate
GetWorkflowExecutionHistoryDescribeWorkflowExecutionListOpenWorkflowExecutionsListClosedWorkflowExecutionsScanWorkflowExecutionsCountWorkflowExecutions
PollWorkflowTaskQueuePollActivityTaskQueueRespondWorkflowTaskCompletedRespondActivityTaskCompletedRecordActivityTaskHeartbeat
Operator Service API
Cluster operations and configuration: Search Attributes:AddSearchAttributesRemoveSearchAttributesListSearchAttributes
AddOrUpdateRemoteClusterRemoveRemoteClusterListClusters
CreateNexusEndpointUpdateNexusEndpointDeleteNexusEndpointListNexusEndpoints
Admin Service API
Advanced administrative operations: Workflow Maintenance:DescribeMutableStateGetWorkflowExecutionRawHistoryResendReplicationTasksRefreshWorkflowTasks
CloseShardGetShard
GetDLQMessagesPurgeDLQMessagesMergeDLQMessages
ImportWorkflowExecution
Namespace Handling
Namespace Registry
The Frontend maintains a cache of namespace metadata:- Loaded from persistence on startup
- Updated via watch mechanism
- Provides fast lookup for request validation
- Handles namespace state transitions
Global Namespaces
For multi-cluster deployments:- Namespaces can be global (replicated across clusters)
- One cluster is “active” for write operations
- Frontend checks if current cluster is active
- Can auto-forward requests to active cluster
Namespace State Machine
Namespaces have states:Registered: Normal operational stateDeprecated: Marked for deletion, read-onlyDeleted: Namespace is removed
HTTP APIs
Nexus HTTP Handler
The Frontend exposes an HTTP endpoint for Nexus operations:- Implements Nexus protocol over HTTP
- Used for cross-namespace workflow invocations
- Supports synchronous and asynchronous operations
OpenAPI HTTP Handler
Provides OpenAPI/Swagger documentation:- Serves OpenAPI specification
- UI for exploring APIs
- Useful for development and debugging
Version Checking
The Frontend checks client and server version compatibility:- Validates SDK versions are supported
- Checks worker build IDs
- Enforces minimum version requirements
- Provides upgrade recommendations
Error Handling
The Frontend translates internal errors to gRPC status codes:- Maps service errors to appropriate gRPC codes
- Adds error details for client consumption
- Sanitizes error messages to avoid leaking internals
Common Error Patterns
InvalidArgument: Request validation failed
NotFound: Workflow or namespace not found
AlreadyExists: Workflow ID already in use
FailedPrecondition: Namespace not active, wrong cluster
ResourceExhausted: Rate limit exceeded
Unavailable: Temporary failure, retry
PermissionDenied: Authorization failed
Configuration
Frontend Service configuration includes:Metrics and Observability
The Frontend emits metrics for:- Request counts per API
- Request latency percentiles
- Error rates by error type
- Rate limiting events
- Long-poll queue depth
Shutdown Behavior
During graceful shutdown:- Health check returns
NOT_SERVING - Drain period allows in-flight requests to complete
- New requests are rejected
- gRPC server stops accepting connections
ShutdownDrainDuration: Time to drain in-flight requestsShutdownFailHealthCheckDuration: When to fail health checks
Further Reading
History Service
Where Frontend routes workflow operations
Matching Service
Where Frontend routes task operations
Architecture Overview
High-level system architecture
Workflow Lifecycle
How requests flow through services