Dubbo-Go-Pixiu AI 推理建设详细落地方案 #859
AlexStocks
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
文档概述
本文档基于 Dubbo-Go-Pixiu 作为高性能 API 网关的定位和现有能力,提供一份生产就绪的 AI 推理功能开发落地方案。
一、项目现状分析
1.1 Dubbo-Go-Pixiu 核心定位
Dubbo-Go-Pixiu 是 Apache Dubbo 生态的下一代 AI/API 网关,具有以下核心职责:
1.2 已有 AI 能力盘点
Pixiu 已经具备以下 AI 相关能力:
1.2.1 LLM Gateway 能力
LLM Registry 适配器 (
pkg/adapter/llmregistry)LLM Endpoint 配置
LLM Tokenizer Filter (
pkg/filter/llm/tokenizer)LLM Proxy Filter (
pkg/filter/llm/proxy)1.2.2 MCP (Model Context Protocol) 能力
MCP Server 适配器 (
pkg/adapter/mcpserver)MCP Server Filter (
pkg/filter/mcp/mcpserver)1.2.3 基础设施能力
集群管理 (
pkg/server/cluster_manager.go)可观测性
治理能力
1.3 与 dubbo-kubernetes 的角色差异
二、Pixiu 的 AI 推理建设目标
基于 Pixiu 的网关定位,其 AI 推理建设应聚焦在 AI Data Plane 层面,即:
2.1 核心目标
三、架构设计
3.1 AI Data Plane 三层架构
3.2 核心组件设计
3.2.1 AI Inference Router(AI 推理路由器)
职责:
实现方式:
pkg/filter/ai/inference_router/配置示例:
3.2.2 AI Inference Cost Manager(推理成本管理)
职责:
实现方式:
pkg/filter/llm/tokenizer配置示例:
3.2.3 AI Model Service Discovery(模型服务发现)
职责:
实现方式:
pkg/adapter/llmregistry支持更多注册中心(Consul、Etcd)元数据扩展:
3.2.4 AI Request Cache(推理请求缓存)
职责:
实现方式:
pkg/filter/ai/cache/配置示例:
3.2.5 AI Batch Processor(批处理优化器)
职责:
实现方式:
pkg/filter/ai/batch/配置示例:
3.2.6 AI Inference Metrics(推理指标采集)
职责:
实现方式:
pkg/prometheus/prometheus.go新增指标:
3.2.7 AI Security & Audit(安全与审计)
职责:
实现方式:
pkg/filter/ai/security/pkg/filter/auth/jwt)配置示例:
四、功能实现路线图
Phase 1:核心推理能力强化(1-2 个月)
目标:完善 LLM 推理的基础能力
任务清单
扩展 LLM Metadata 模型
model_version,model_capabilities,cost_per_token等字段pkg/model/llm.go实现 AI Inference Router Filter
pkg/filter/ai/inference_router/增强 Cost Tracking
pkg/filter/llm/tokenizer以支持成本计算实现 AI Request Cache
pkg/filter/ai/cache/新增 AI 专用 Metrics
文档和示例
交付物
Phase 2:高级治理与优化(2-3 个月)
目标:提升推理性能和治理能力
任务清单
实现 AI Batch Processor
pkg/filter/ai/batch/语义缓存(Semantic Cache)
模型健康检查增强
多注册中心支持
pkg/adapter/llmregistry支持 Consul、EtcdAI Security Filter
pkg/filter/ai/security/分布式追踪增强
交付物
Phase 3:智能调度与成本优化(2-3 个月)
目标:实现智能模型调度和成本优化
任务清单
智能路由策略
请求优先级队列
pkg/filter/ai/priority/成本预警和自动降级
模型资源池化
请求合并与去重
AI Dashboard(可选)
admin/web)交付物
Phase 4:生态集成与最佳实践(1-2 个月)
目标:完善生态集成和沉淀最佳实践
任务清单
Kubernetes Operator 集成
controllers/目录AIInferencePolicy多云 LLM Provider 集成
Self-Hosted Model 支持
MCP 能力增强
性能测试和基准
tools/benchmark进行性能测试最佳实践文档
交付物
五、技术实现细节
5.1 目录结构设计
5.2 关键接口设计
5.2.1 AI Inference Router Interface
5.2.2 AI Cost Manager Interface
5.2.3 AI Cache Interface
5.3 配置文件示例
5.3.1 完整的 AI 推理配置
六、性能与成本优化策略
6.1 性能优化
请求缓存
批处理
连接池化
异步非阻塞
6.2 成本优化
智能路由
用户配额管理
请求去重
模型降级
七、可观测性与监控
7.1 核心指标
业务指标
ai_inference_requests_total:推理请求总数(按模型、用户、状态)ai_inference_cost_usd_total:推理成本总计(美元)ai_inference_tokens_total:Token 消耗总数(按输入/输出)ai_inference_cache_hit_ratio:缓存命中率性能指标
ai_inference_latency_seconds:推理延迟(P50/P95/P99)ai_inference_queue_length:请求队列长度ai_inference_batch_size:批处理大小分布健康指标
ai_inference_endpoint_health:端点健康状态ai_inference_fallback_count:降级次数ai_inference_error_rate:错误率7.2 日志采集
审计日志
{ "timestamp": "2026-01-04T14:00:00Z", "user_id": "tenant-001", "model": "gpt-4", "version": "v1.0", "prompt_hash": "sha256:abcd...", "input_tokens": 120, "output_tokens": 350, "cost_usd": 0.0135, "latency_ms": 1234, "endpoint": "openai-primary", "cache_hit": false, "status": "success" }7.3 Grafana Dashboard
提供预配置的 Grafana Dashboard,包含:
八、安全与合规
8.1 认证与授权
JWT Token 认证
dgp.filter.auth.jwtAPI Key 管理
RBAC/ABAC
8.2 数据安全
PII 脱敏
传输加密
审计日志
8.3 合规性
GDPR 合规
SOC 2 合规
九、测试与验证
9.1 单元测试
9.2 集成测试
9.3 性能测试
使用
tools/benchmark进行压测:9.4 混沌测试
十、部署与运维
10.1 部署模式
模式 1:独立 AI Gateway
模式 2:Sidecar
10.2 资源规划
推荐配置(中等规模)
大规模部署
10.3 监控告警
关键告警
十一、风险与挑战
11.1 技术风险
11.2 运维风险
十二、总结与展望
12.1 Pixiu 在 AI 推理中的核心价值
Beta Was this translation helpful? Give feedback.
All reactions