0Pricing
AI Prompt Engineering · Lesson

Deployment and Rollback Strategies

Blue-green prompt deployment, feature flags, and rollback on regression.

Prompt Deployment Challenges

Deploying a new prompt version to production carries real risk — a change that improves average quality may hurt edge cases, cause latency spikes, or confuse users. Controlled deployment strategies manage this risk by limiting blast radius and enabling rapid rollback.

Blue-Green Prompt Deployment

Blue-green deployment maintains two environments: blue (current production) and green (new version). Traffic is switched atomically from blue to green after validation. If green fails, the switch reverts instantly.

  • Zero-downtime switches
  • Both versions stay ready simultaneously
  • Rollback is a single config change, not a redeploy
# prompt_router.py — blue/green traffic control
class PromptRouter:
    def __init__(self):
        self.slots = {
            'blue': None,   # {'prompt_id': ..., 'version': ...}
            'green': None,
        }
        self.active_slot = 'blue'

    def load_slot(self, slot, prompt_id, version, template):
        self.slots[slot] = {
            'prompt_id': prompt_id,
            'version': version,
            'template': template
        }
        print(f'Loaded {prompt_id}@{version} into {slot} slot')

    def switch_to(self, slot):
        if not self.slots[slot]:
            raise ValueError(f'Slot {slot} is empty')
        self.active_slot = slot
        info = self.slots[slot]
        print(f'Traffic now routed to {slot}: {info["prompt_id"]}@{info["version"]}')

    def get_active_template(self):
        return self.slots[self.active_slot]['template']

All lessons in this course

  1. Prompt Registry Architecture
  2. Version Control for Prompts
  3. Deployment and Rollback Strategies
  4. Monitoring Prompt Performance in Production
← Back to AI Prompt Engineering