Cloud concept · Updated

Content-Based Routing - Content-based routing directs a request or message to a destination by evaluating its payload, attributes, or derived meaning.

In short

Instead of distributing requests solely by availability or load, content-based routing selects a destination suited to each request’s characteristics. In generative AI applications, it can match tasks to specialized foundation models while balancing quality, latency, cost, and security constraints.

Cloud Concepts Hub →

6 key aspects of Content-Based Routing

Effective content-based routing combines request interpretation, explicit eligibility rules, measured optimization, and observable failure handling.

01
Request-aware destination selection

Inspect structured attributes or derive features from the payload to select a processing destination. Use trusted metadata where possible, and validate client-provided routing hints before applying them.

02
Static rules and runtime classification

Use predefined mappings for predictable categories and runtime classifiers when task intent must be inferred. A hybrid design can avoid classifier overhead for requests that deterministic rules already resolve.

03
Constraint-first model eligibility

Filter candidates by modality, context capacity, authorization, and data-handling requirements before comparing cost or latency. Never let an optimization policy select a model that cannot safely process the request.

04
Measured quality, cost, and latency

Base selection policies on representative model evaluations and operational telemetry. Track performance by task category and include routing overhead when calculating end-to-end cost and latency.

05
Explicit defaults and constrained fallbacks

Define what happens when classification is ambiguous, no eligible destination exists, or a model fails. Bound retries and ensure every fallback satisfies the original request’s security and capability constraints.

06
Traceable routing policies

Version routing rules and record why each destination was chosen. Use these records to reproduce decisions, compare policy versions, and detect regressions without retaining unnecessary sensitive content.

Cloud services for Content-Based Routing

API Gateway can validate requests and normalize routing metadata before invoking Lambda or starting a Step Functions workflow. Lambda applies deterministic rules or derives classification attributes, and Step Functions coordinates branches, model calls, retries, and constrained fallbacks. Amazon Bedrock supplies eligible foundation models and, where its supported configurations fit the use case, managed prompt-routing capabilities. CloudWatch captures decision logs and operational measurements that inform policy updates. Together, these services separate API handling, selection logic, execution, and observation; quality evaluations and security constraints still need to be designed explicitly rather than inferred from infrastructure metrics.

AWS Step FunctionsAWS Step Functions

Orchestrates classification, branching, model invocation, and fallback handling. Choice states route on structured workflow data, so semantic decisions require a preceding classifier or application task that produces usable routing attributes.

AWS LambdaAWS Lambda

Runs application code for static routing tables, request classification, eligibility checks, and metrics-informed model selection. Functions can validate routing inputs and invoke the selected model through its API.

Amazon Bedrock

Provides foundation model APIs that an application or workflow can select according to task requirements. Its intelligent prompt routing capability can also select between supported models within configured router options; it should not be treated as an unrestricted router across arbitrary models or endpoints.

Amazon API GatewayAmazon API Gateway

Provides the API entry point for authentication, validation, and supported request transformations. REST API mapping templates can prepare routing metadata for a backend, while complex content interpretation and arbitrary model selection remain backend responsibilities.

Amazon CloudWatchAmazon CloudWatch

Collects logs and operational metrics used to evaluate routing behavior, including per-route latency, errors, and custom measurements. Routing code must consume or otherwise incorporate these signals into its policy; CloudWatch does not select models automatically.

Content-Based Routing exam questions

Real practice exam questions on Content-Based Routing, with the correct answer and its explanation. Answer them with every option in the exam simulator.

DVA-C02

A media-processing application publishes upload notifications to an Amazon SNS topic. Every notification includes a String message attribute named mimeType, with values such as image/jpeg, image/png, or application/pdf. Uploads awaiting security review also include a String message attribute named quarantined with the value "true". Other uploads omit the quarantined attribute. The JSON message body contains only the object's bucket and key.

A thumbnail-generation function subscribes to the topic but currently receives every notification. A developer must configure this subscription to receive only notifications whose mimeType starts with image/ and whose quarantined attribute is absent. Unwanted notifications must be filtered before delivery, without changing the publisher.

Which subscription configuration meets these requirements?

Show answerCORRECT ANSWER

Set FilterPolicyScope to MessageAttributes and set FilterPolicy to {"mimeType":[{"prefix":"image/"}],"quarantined":[{"exists":false}]}.

MessageAttributes filtering evaluates the supplied SNS attributes. The prefix condition matches image MIME types, and exists:false requires the quarantined attribute to be absent. Conditions for different attribute names are combined with AND, so SNS delivers only notifications that satisfy both requirements.

SAP-C03

A company centralizes operational events from 40 AWS accounts on a custom Amazon EventBridge event bus named operations in a shared-services account. Each workload account has a rule that forwards events directly to this bus. Some workload accounts are in different AWS Regions, and the destination Region supports cross-Region event-bus routing. The forwarding roles and destination bus policy are configured correctly. An archive on the operations bus confirms that forwarded events are arriving.

All workload accounts publish events with source "com.example.batch" and detail-type "Batch Failed". The detail object contains only jobId and status. A remediation workflow in the shared-services account must run only for events originating in two designated production accounts. Events from all other accounts must continue arriving on the operations bus for other consumers.

An existing rule targets the remediation workflow and matches the source, detail-type, and the shared-services account ID in the top-level account field. However, the rule was deployed on the shared-services account's default event bus, and the workflow is never invoked. Target invocation permissions are already correct.

Which change will meet the requirements without modifying the publishers or forwarding rules?

Show answerCORRECT ANSWER

Create the remediation rule on the operations bus. Match the existing source and detail-type values and match the two production account IDs in the top-level account field. Remove the ineffective default-bus rule.

Receiving rules must be attached to the bus that receives the forwarded events. Cross-account forwarding preserves the originating account in the event's top-level account field. A rule on the operations bus that matches the two production account IDs invokes remediation only for those accounts while leaving other events available to other consumers.

SAA-C03

A company exposes a document-processing API through an Application Load Balancer (ALB) that terminates HTTPS on port 443. The ALB forwards all requests to a fleet of EC2 reverse proxies. Each proxy inspects the HTTP header X-Processing-Class: requests with the value economy go to a low-cost processing fleet, and all other requests go to a standard processing fleet. Both processing fleets span two Availability Zones and accept requests directly from the ALB.

All clients use the same hostname and POST /process path. Clients cannot change their URLs, ports, or request format. The company wants to eliminate the reverse proxy fleet's compute costs while preserving the routing behavior and Availability Zone resilience.

Which solution meets these requirements?

Show answerCORRECT ANSWER

Create a target group for each processing fleet. Configure the existing HTTPS listener to forward requests to the economy target group when the HTTP header X-Processing-Class equals economy, and use the standard target group as the default action. Remove the reverse proxy fleet.

An ALB listener rule can inspect an HTTP header and forward matching requests to a specific target group. A header condition for X-Processing-Class equal to economy, followed by a default action to the standard fleet, preserves the existing behavior. Registering each fleet's targets across both Availability Zones retains resilience while removing the proxy compute costs.

Practice Content-Based Routing in a full exam

Questions on Content-Based Routing in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

What is Content-Based Routing

3 min read

Content-based routing is an integration pattern in which a router examines a request or message and selects an appropriate destination. Routing inputs can include structured fields, headers, language, document type, task category, or features extracted from unstructured text. The destination might be a processing workflow, service endpoint, queue, or foundation model. The defining characteristic is that the request’s content or attributes influence the decision, rather than every request following the same path.

For foundation model integrations, a router might send straightforward classification tasks to a smaller model, source-code questions to a model evaluated for coding, and image-containing requests to a model that supports the required modality. A long document may require a model with a larger context window. These decisions should start with eligibility constraints, such as supported input formats, regional availability, data-handling requirements, and context limits, before optimizing cost or response time.

A static routing configuration uses predefined rules, often implemented in application code or a versioned configuration file. For example, a trusted task field with the value translation can map to a particular model endpoint. Static does not mean every request uses the same model: it means the selection policy is predefined rather than learned or adjusted automatically. Explicit rules are inexpensive and explainable, but become harder to maintain when categories overlap or inputs lack reliable structure.

Dynamic routing can derive a task category or complexity estimate at runtime. A classifier can examine the prompt and return a validated label, after which an orchestrator selects a specialized model. In AWS Step Functions, a classification task can populate workflow state and a Choice state can branch on that result. Choice states evaluate configured conditions; they do not independently understand natural language. Calling a classifier adds latency and cost, so a simple rules-first path is often appropriate for clearly identifiable requests.

Metrics-driven routing adds measured model performance to the decision. Evaluate candidate models on representative task categories and record quality scores, token costs, latency distributions, throttling, and failure rates. A routing policy can select the lowest-cost eligible model that meets a quality target and latency objective. Quality usually requires offline evaluation or application feedback rather than an infrastructure metric alone. Update policies through controlled releases and monitor performance by task category so aggregate averages do not hide poor routing for less common requests.

An API gateway can authenticate clients, validate request structure, and transform incoming fields into a consistent routing envelope. For example, an Amazon API Gateway REST API mapping template can normalize task metadata before forwarding it to a routing backend. Request transformation is not equivalent to arbitrary semantic model selection, and transformation capabilities differ by API type. Keep complex classification and model-selection logic in application code or an orchestrated workflow rather than assuming the gateway automatically chooses a model from the request body.

Production designs need an explicit default route, handling for ambiguous classifications, and bounded retries or fallback paths. A fallback must preserve security and capability requirements; an unavailable approved model is not permission to send sensitive data elsewhere. Treat client-supplied routing hints and classifier output as untrusted input, and map them to an allowlisted set of destinations. Record the policy version, selected model, decision reason, and relevant operational metrics without unnecessarily logging sensitive prompts. Unlike ordinary load balancing, content-based routing matches requests to capabilities; it can use load signals, but distributing traffic alone does not make a system content-aware.

Learn Content-Based Routing in lessons

5 short lessons on Content-Based Routing in 4 certification courses.

Open the lessons