Files
myWiki/concepts/batch-vs-real-time-inference.md

45 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "批处理推理 vs 实时推理"
created: 2026-06-19
updated: 2026-06-19
type: concept
tags: [inference, deployment, batch-processing, real-time, latency, throughput]
sources:
- https://towardsdatascience.com/six-choices-every-ai-engineer-has-to-make-and-nobody-teaches/
---
# 批处理推理 vs 实时推理
## 两种架构
批处理和实时推理是两种**不同的系统架构**。选择错误的选项会影响基础设施、成本和用户体验——这些选择难以逆转。
| | 批处理推理 | 实时推理 |
|---|---|---|
| **生成方式** | 按时间表(每小时/每天) | 按需,毫秒到秒 |
| **存储** | 预计算,存数据库 | 即时计算 |
| **成本** | 低 | 高24/7 运行) |
| **基础设施** | 简单,易调试 | 更多活动部件,难监控 |
| **数据新鲜度** | 可能过时 | 始终最新 |
## 系统层面的权衡
- 更大的批处理 → 更高吞吐量,但每个请求延迟也更高
- 实时系统使用 batch_size=1 → 速度快,但可能降低效率
## 最常见的错误
**团队默认使用实时推理,因为听起来更令人印象深刻。** 但大多数业务问题不需要亚秒级预测:
- 每晚的流失率评分
- 每周的推荐更新
- 每天的欺诈模式更新
## 决策信号
> 如果你的用户不会注意到预测是 5 分钟前还是 5 毫秒前,用批处理推理。
## 参考
- [[ai-production-tradeoffs|AI 生产权衡]]
- [[nobrega-ai-production-tradeoffs-2026|原文文章]]