← Back to Index

15. Trade-Offs

Every ML system design decision involves trade-offs. The ability to recognize, articulate, and navigate trade-offs is what separates senior from junior engineers.

Accuracy vs Latency

ApproachAccuracyLatencyCost
Large deep ensemble (3 models)Best (AUC 0.96)~150ms3 GPUs
Single XGBoostGood (AUC 0.93)~20ms1 CPU
Linear modelModerate (AUC 0.88)~2msMinimal
Rule-based heuristicLow (AUC 0.80)~1msNone

How to decide: Let business requirements drive the choice. If a 3% accuracy gain is worth $1M/year in revenue, use the ensemble. If latency SLA is p99 < 50ms, use XGBoost.

Freshness vs Stability

Cost vs Redundancy

Consistency vs Availability (CAP for ML)

ScenarioChoiceRationale
Fraud detection (financial loss on stale data)Strong consistencyStale features = wrong fraud decision
Content recommendationsEventual consistencyStale recommendations still reasonable
Real-time bidding (must respond fast)Available over consistentBetter to serve slightly stale data than miss the bid

Batch vs Real-Time Training

Model Complexity vs Interpretability

# Trade-off visualization
Simple (Logistic Regression):
  ✓ Interpretable (coefficients = feature importance)
  ✓ Fast training and inference
  ✗ Lower accuracy for complex patterns

Complex (Deep Neural Network):
  ✓ Highest accuracy
  ✗ Black box (needs SHAP/LIME for explanation)
  ✗ Expensive training and inference

Middle ground: Gradient Boosted Trees (XGBoost, LightGBM)
  ✓ High accuracy
  ✓ Feature importance available
  ✓ Reasonably fast
Exercise: You are designing a real-time ML system for stock trading signals. Identify 5 key trade-offs. For each: describe the two options, the pros/cons of each, and make a recommendation with justification. Consider: latency vs accuracy, model complexity vs speed, batch vs online training, consistency vs availability, cost vs redundancy.