Deploy & inference
Real-time endpoint
For low-latency request/response inference.
validated request payload + optional retrieved features
low-latency model response + operational metrics
I use real-time hosting when request latency matters and traffic justifies continuously available endpoint capacity.
Mental model
What this means before worrying about syntax.
Deploy the model behind a persistent SageMaker endpoint sized for required latency and throughput.
- Real-time endpoint is persistent managed infrastructure for low-latency request/response scoring.
- End-to-end latency includes feature retrieval, network, serialization and model execution.
- Capacity planning matters as much as model correctness.
application -> endpoint -> inference container -> prediction
Implementation anatomy
The sequence you would actually build or configure.
- 1
Deploy model/variant.
- 2
Application invokes endpoint.
- 3
Container deserializes/preprocesses/predicts/serializes.
- 4
Track latency/errors/throttles/utilization.
- 5
Configure autoscaling and safe deployment/rollback.
Concrete example
A real model-development or production flow.
Card authorization arrives
Retrieve online card/merchant features
Invoke fraud endpoint
Return probability within latency budget
Decision service combines score with policy
Implementation lab
Concrete code, data manipulation and configuration for this lifecycle step.
Application-side inference flow
This makes the boundary explicit: orchestration/feature retrieval sits around the endpoint; the endpoint scores a well-defined payload.
def score_transaction(request, feature_client, endpoint):
customer = feature_client.get_customer(request["customer_id"])
card = feature_client.get_card(request["card_id"])
vector = {
"amount": request["amount"],
"tx_count_5m": card["tx_count_5m"],
"avg_amount_30d": card["avg_amount_30d"],
"merchant_risk": request["merchant_risk"],
"customer_tenure_days": customer["tenure_days"],
}
result = endpoint.invoke(data=vector)
return {
"transaction_id": request["transaction_id"],
"fraud_probability": result["fraud_probability"],
"model_version": result["model_version"],
}
Measure end-to-end latency, not only model latency
from time import perf_counter
t0 = perf_counter()
features = load_online_features(card_id)
t1 = perf_counter()
prediction = endpoint.invoke(data=features)
t2 = perf_counter()
print({
"feature_lookup_ms": (t1 - t0) * 1000,
"endpoint_ms": (t2 - t1) * 1000,
"end_to_end_ms": (t2 - t0) * 1000,
})
Design decisions that matter
- Latency SLO.
- Minimum capacity/autoscaling.
- Availability and rollout strategy.
- Model score vs final business decision separation.
Common failure modes
- Autoscaling is not instantaneous.
- Feature-store/network hops can dominate latency.
- Large models may violate SLO even if endpoint is technically healthy.
Production readiness check
Items to close before treating this step as production-ready.