LogoLogo
WebsiteSlack
0.36
0.36
  • Get started
  • Overview
  • Clusters
    • Management
      • Auth
      • Create
      • Update
      • Delete
      • Environments
    • Instances
      • Multi-instance
      • Spot instances
    • Observability
      • Logging
      • Metrics
      • Alerting
    • Networking
      • Load balancers
      • VPC peering
      • HTTPS
      • Custom domain
    • Advanced
      • Setting up kubectl
      • Private Docker registry
      • Self hosted images
  • Workloads
    • Realtime
      • Example
      • Configuration
      • Containers
      • Autoscaling
      • Traffic Splitter
      • Metrics
      • Statuses
      • Troubleshooting
    • Async
      • Example
      • Configuration
      • Containers
      • Statuses
    • Batch
      • Example
      • Configuration
      • Containers
      • Jobs
      • Statuses
    • Task
      • Example
      • Configuration
      • Containers
      • Jobs
      • Statuses
  • Clients
    • Install
    • Uninstall
    • CLI commands
    • Python client
Powered by GitBook
On this page
  • Configuration
  • Example
  • Deploy a traffic splitter
  • Update the weights
  • Update the target APIs
  1. Workloads
  2. Realtime

Traffic Splitter

Traffic Splitters can be used to expose multiple RealtimeAPIs as a single endpoint for A/B tests, multi-armed bandits, or canary deployments.

Configuration

- name: <string>  # name of the traffic splitter (required)
  kind: TrafficSplitter  # must be "TrafficSplitter" for traffic splitters (required)
  networking:  # networking configuration (default: see below)
    endpoint: <string>  # the endpoint for the traffic splitter (default: <name>)
  apis:  # list of Realtime APIs to target (required)
    - name: <string>  # name of a Realtime API that is already running or is included in the same configuration file (required)
      weight: <int>   # percentage of traffic to route to the Realtime API (all non-shadow weights must sum to 100) (required)
      shadow: <bool>  # duplicate incoming traffic and send fire-and-forget to this api (only one shadow per traffic splitter) (default: false)

Example

This example showcases Cortex's Python client, but these steps can also be performed by using the Cortex CLI.

Deploy a traffic splitter

traffic_splitter_spec = {
    "name": "sentiment-analyzer",
    "kind": "TrafficSplitter",
    "apis": [
        {"name": "sentiment-analyzer-a", "weight": 50},
        {"name": "sentiment-analyzer-b", "weight": 50},
    ],
}

cx.deploy(traffic_splitter_spec)

Update the weights

new_traffic_splitter_spec = {
    "name": "sentiment-analyzer",
    "kind": "TrafficSplitter",
    "apis": [
        {"name": "sentiment-analyzer-a", "weight": 1},
        {"name": "sentiment-analyzer-b", "weight": 99},
    ],
}

cx.deploy(new_traffic_splitter_spec)

Update the target APIs

new_traffic_splitter_spec = {
    "name": "sentiment-analyzer",
    "kind": "TrafficSplitter",
    "apis": [
        {"name": "sentiment-analyzer-b", "weight": 50},
        {"name": "sentiment-analyzer-c", "weight": 50},
    ],
}

cx.deploy(new_traffic_splitter_spec)
PreviousAutoscalingNextMetrics

Last updated 3 years ago