Guides | FluxGate Docs

Advanced Usage Patterns

High-Performance API Gateway for Microservices. Master resilience, traffic routing, and cross-origin policies with production-ready configurations.

fluxgate apply --config advanced-routing.yaml

Implementing Circuit Breakers

Prevent cascading failures when downstream services degrade. FluxGate monitors latency and error rates to automatically isolate unhealthy endpoints before timeouts propagate to your frontend.

  • Failure ThresholdTriggers open state after 5 consecutive 5xx responses or latency exceeding 450ms.
  • Half-Open ProbesSends a single test request every 15 seconds to validate service recovery before full traffic restoration.
  • Fallback RoutingSeamlessly redirects traffic to `inventory-backup.us-east-1` or returns cached responses with `X-Cache: HIT`.
routes:
  - path: /api/v1/inventory
    circuit_breaker:
      enabled: true
      failure_threshold: 5
      latency_threshold_ms: 450
      recovery_timeout_s: 15
      fallback:
        type: static_response
        status: 200
        body: '{"status": "degraded", "cache": true}'

Configuring Weighted Load Balancing

Distribute traffic across microservice instances based on hardware capacity, region latency, or canary deployment percentages without modifying application code.

Weighted Round Robin

Production Standard

Assign static weights to backend pools. Ideal for blue-green deployments where 90% of traffic routes to `stable-v2` and 10% to `canary-v3`.

Least Connections

High Concurrency

Dynamically routes requests to the instance with the fewest active TCP connections. Automatically adjusts for variable request processing times.

load_balancer:
  strategy: weighted_round_robin
  backends:
    - name: payment-service-prod
      hosts:
        - 10.0.4.12:8080
        - 10.0.4.13:8080
        - 10.0.4.14:8080
      weights: [50, 30, 20]
      health_check:
        path: /healthz
        interval_s: 5

Handling CORS Preflight Requests

Automate `OPTIONS` request interception and inject precise `Access-Control-*` headers. Keep your origin servers lean while maintaining strict browser security compliance.

cors:
  enabled: true
  allowed_origins:
    - https://dashboard.fluxgate.io
    - https://admin.internal.network
  allowed_methods: ["GET", "POST", "PUT", "DELETE"]
  allowed_headers: ["Authorization", "X-Request-ID", "Content-Type"]
  expose_headers: ["X-RateLimit-Remaining"]
  max_age_s: 86400
  allow_credentials: true
  • Preflight CachingSets `Access-Control-Max-Age` to 24 hours, reducing browser overhead for frequent API consumers.
  • Origin ValidationStrictly matches request origins against the allowlist. Rejects wildcard `*` when credentials are enabled for compliance.
  • Header InjectionAutomatically appends rate-limit and trace headers to preflight responses for observability dashboards.
99.99% Uptime SLA
12ms Avg Route Latency
2.4M Requests/sec
0 Config Restarts