最新资讯
dev.to 在信任 AI 生成的测试用例前,如何逐条复核 unite.ai Franklin Templeton 构建 AI 研究工作流以揭示风险 techxplore.com AI 助力寻找更优的钛合金 3D 打印工艺参数 engadget.com Perplexity 推出“teammates”日常工作任务 AI agent computerworld.com 别提数据中心:OpenAI 改称“compute campuses” theguardian.com 俄美试图阻止就自主武器制定具有约束力的规则 bloomberg.com Nvidia 加强东南亚芯片追踪以打击走私 thestack.technology 模型路由需求升温,Agent Router 推出开源替代方案 www.youtube.com Google DeepMind 的 Philipp Schmid:AI 同事需要具备的七个要素 unite.ai Cashfree 为 AI Agent 的托管结账加入 WebMCP 工具 dev.to 我们在 DolphinBench 上测试记忆检索:纯关键词搜索暴露了自身回归 dev.to 别再把 Agent 写成 while 循环,把它建模为状态机
多元动态
登录 注册
大模型 dev.to · @Dhananjay Lakkawar

无服务器超级计算机:用 48 美元生成 100 万份 AI 简报

原文 我的收藏

文章以数学题形式说明 B2C AI 应用的成本困境:为 100 万免费用户每天生成个性化 AI 简报,若同步调用 OpenAI、Anthropic 或 Amazon Bedrock 等托管 API,会立即触发 TPM 限流并需大量重试与退避;按每请求 0.01 美元计算,仅推理每天就要约 1 万美元。作者主张对高批量、相互隔离的任务停止使用外部 LLM API 的 HTTP 调用,改用无服务器批处理方案。正文片段截断,48 美元方案的具体实现与验证未完整给出。

AI推荐理由 讨论 B2C AI 应用的高并发成本问题:向托管 API 同步发送 100 万请求会触发 TPM 限流,按每请求 0.01 美元计每天推理成本约 1 万美元;作者主张对高批量隔离任务改用无服务器批处理而非外部 LLM HTTP 调用。问题设定具体、有工程参考价值,但正文片段截断,$48 方案细节与验证未完整呈现。

68

正文

Here is a math problem that is currently destroying the margins of B2C AI startups. You have a successful B2C app. You want to generate a highly personalized, daily AI briefing for your 1,000,000 free-tier users, and deliver it to their inboxes every morning at 8:00 AM. If you attempt to send 1,000,000 concurrent requests to a managed API like OpenAI, Anthropic, or Amazon Bedrock, two things will happen: You will hit the wall: You will be instantly throttled by Tokens-Per-Minute (TPM) limits. Processing 1 million users synchronously through a managed API will take hours of retries and exponential backoffs. You will burn your runway: At just $0.01 per prompt/response, it will cost you $10,000 every single morning just for inference. You cannot offer Generative AI to free-tier users if your infrastructure scales linearly in cost and bottlenecks on third-party rate limits. The Pivot: We must stop making HTTP network calls to external LLM APIs for high-volume, isolated batch tasks. Instead, we can turn AWS Lambda into a 10,000-node ephemeral AI supercomputer. By packaging a quantized, open-source model into AWS Lambda, we can generate 1,000,000 personalized AI responses in minutes, scale back to zero immediately, and drop our inference cost by 99%. Here is how to architect the "Bring-Your-Own-LLM" Supercomputer Swarm on AWS. The Architecture: The 7-Service Swarm To execute this, we use the Scatter-Gather (Map-Reduce) pattern, leveraging AWS Step Functions and serverless CPU inference. 1. The Trigger (Amazon S3) At 7:50 AM, your backend data pipeline dumps a massive CSV or JSON Lines file into Amazon S3. This file contains 1,000,000 rows of user context (recent clicks, portfolio data, reading history). 2. The Concurrency Engine (AWS Step Functions) The S3 upload triggers an AWS Step Function utilizing the Distributed Map state. Distributed Map is purpose-built for massive S3 data processing. It natively reads the massive CSV, chunks it into manageable batches, and requests up to 10,000 concurrent AWS Lambda executions instantly. 3. The AI Image (Amazon ECR) Where is the AI? You deployed a Docker container to Amazon Elastic Container Registry (ECR). Inside this container is llama.cpp and a lightning-fast, highly capable quantized model like Meta's Llama 3.2 3B (which compresses down to ~2GB and easily fits within Lambda's 10GB container limit). 4. The Ephemeral Swarm (AWS Lambda) AWS spins up up to 10,000 concurrent Lambda functions, each provisioned with 4GB of RAM and ARM64 Graviton processors. The Llama 3.2 model loads directly into Lambda’s local memory. Because inference happens entirely locally on the CPU, there are no network API calls, no network latency, and absolutely no TPM rate limits. The cluster processes the users in massive parallelization. 5. The Shock Absorber (Amazon Kinesis Firehose) 10,000 Lambdas simultaneously writing 1,000,000 generated AI briefings to a standard Postgres database would cause a catastrophic connection-pool exhaustion. Instead, the Lambdas stream their output JSON directly into Kinesis Data Firehose, which is natively designed to absorb massive write spikes. 6. The Formatter (AWS Glue & S3) As data flows through Firehose, it buffers and uses AWS Glue to seamlessly convert the 1,000,000 AI responses into a highly optimized Parquet file, dropping it into a final S3 bucket. 7. The Delivery (Amazon SES) The arrival of the final Parquet file triggers Amazon Simple Email Service (SES) to instantly blast out the 1,000,000 customized AI briefings to your users' inboxes right at 8:00 AM. The CTO Perspective: The Grounded Economics When I explain this to engineering leaders, the reaction is usually a mix of disbelief and immediate validation: "Wait... instead of paying a managed API provider $10,000 and waiting hours for rate limits to clear, we can spin up a 10,000-node AI supercomputer on AWS Lambda and process everyone in minutes?" Yes. Let's do the exact math using verified AWS pricing (us-east-1). The Physics of CPU Inference: A 4GB Lambda using Graviton2/3 processors running a quantized 3B model via llama.cpp can generate roughly 15 to 20 tokens per second. If we are generating a highly punchy, personalized "Daily Insight" of ~50 tokens per user, it takes roughly 3 seconds of compute per user. The Batching Math: Let's assume each of the 10,000 concurrent Lambdas receives a batch of 30 users. Compute time per Lambda: 30 users × 3 seconds = 90 seconds of execution time. 10,000 Lambdas running for 90 seconds processes 300,000 users. Step Functions loops this ~3.3 times. Total time to process 1,000,000 users: ~5 minutes. The Cost Math: Total Execution: 1,000,000 users × 3 seconds = 3,000,000 seconds of compute. Lambda Memory: 4GB (4096 MB). Total Compute: 3,000,000 seconds * 4 GB = 12,000,000 GB-seconds. AWS ARM64 Pricing: $0.0000133334 per GB-s. Total Inference Cost: 12,000,000 * 0.0000133334 = $160.00. (Note: If your output is even shorter—say, a 15-token classification tag—your compute time drops drastically, and your cost approaches the legendary *$48.00** mark for a million users).* Even at $160, you have completely eliminated the $10,000 API bill. You just reduced your Generative AI COGS (Cost of Goods Sold) by 98.4%. Engineering Reality Check: Tradeoffs and Constraints Before you deploy this tomorrow, you must design around these physical AWS constraints: 1. Concurrency Quotas AWS Lambda scales brilliantly, but a new AWS account defaults to 1,000 concurrent executions per region. To achieve a 10,000-node swarm, you must open an AWS Support ticket and request a Lambda Concurrent Executions Quota Increase. AWS grants these readily for valid batch workloads. 2. Cold Starts Loading a 2GB model file from the container image into Lambda's RAM takes time—usually 5 to 15 seconds. Because this is an asynchronous batch job orchestrated by Step Functions, cold starts do not matter. Your end-users are asleep. But do not try to use this exact architecture for a real-time website chatbot. 3. Model Size vs. Intelligence You cannot run Claude 3.5 Sonnet or GPT-4o inside AWS Lambda. You are running 3-Billion to 8-Billion parameter open-source models (Llama 3.2, Mistral). These models are incredibly capable at summarization, entity extraction, and basic personalization, but they will fail at complex, PhD-level reasoning tasks. Match the model to the workload. The Bottom Line The AI industry wants you to believe that the only way to utilize Generative AI is to pay a toll bridge to a massive API provider. By leveraging the distributed power of AWS Step Functions, the 10GB container capacity of AWS Lambda, and the incredible efficiency of open-source models, you can take control of your unit economics. Stop waiting in line for API rate limits. Build the swarm. Are you running batch AI inference workloads in production? Have you hit the TPM wall with managed APIs yet? Let's discuss your architecture in the comments below!

来源报道 · 1 篇 · 以下链接均前往原始媒体

← 返回精选动态 原文

更多内容