返回提示词目录第 1397 页

无服务器应用架构设计

评估应用对无服务器架构的适配性,输出架构图、函数与数据设计、容错部署方案及成本测算方法。

完整提示词

<context>
Serverless works best for spiky or low-traffic workloads, event processing and glue between managed services, where paying per invocation and not running servers outweighs the constraints. Those constraints shape the design: functions are stateless and short-lived with execution time, payload and concurrency limits; cold starts add latency for some runtimes and package sizes; connections to relational databases exhaust quickly unless pooled through a proxy or replaced by HTTP-based data services; every trigger has its own retry and batching semantics, so handlers must be idempotent and failures need dead-letter destinations. The common mistakes are one function per tiny endpoint that becomes unmanageable, or a whole framework in one function; chaining functions synchronously; and no way to run and test locally. At steady high throughput, containers are often cheaper, and long-running or stateful work belongs in a workflow service or containers.
</context>

<task>
<application>
{{application}}
</application>

<platform>
{{platform}}
</platform>

{{#constraints}}
<constraints_given>
{{constraints}}
</constraints_given>
{{/constraints}}

1. Check fit: traffic shape, task durations, latency targets, state needs and team experience. Say which parts suit serverless and which should run elsewhere (containers, a workflow service), and why.
2. Draw the architecture: entry points, functions, triggers (HTTP, queue, schedule, storage, stream), managed services and data stores.
3. Design functions: grouping by bounded capability rather than one per endpoint or one for everything, runtime choice, memory and timeout settings as starting points, and how shared code is packaged.
4. Design state and data: data store choice and access patterns, connection handling for relational databases, caching, file storage, and where session or workflow state lives.
5. Cover limits and failure handling: per-trigger retry semantics, idempotency, dead-letter destinations, concurrency limits and reserved capacity to protect downstream systems, payload limits and how large data is passed by reference, and cold start mitigations where the latency target requires them.
6. Cover development and deployment: infrastructure as code, local emulation and integration tests against real cloud resources, environments, observability with structured logs and tracing, and secrets.
7. Describe the cost shape: what drives cost (invocations, duration, memory, data transfer, managed service requests), and the traffic level at which containers would be cheaper, as a method to calculate rather than invented prices.
</task>

<constraints>
- Do not chain functions with synchronous calls when a queue or workflow service fits.
- Every queue- or stream-triggered handler must be idempotent and have a failure destination.
- Do not quote platform limits or prices as facts; give the dimension and say to check current documentation.
- Say plainly if serverless is a poor fit for part or all of the application.
{{> output/uncertainty}}
</constraints>

<output_format>
## Fit check
Table: part of the application, serverless fit (good, poor), reason.
## Architecture
Mermaid flowchart.
## Function design
Table: function, trigger, responsibility, timeout and memory starting point.
## State and data
## Limits and failure handling
## Development and deployment
## Cost shape
## Open questions
Numbered.
</output_format>

可替换内容

  • {{application}}
  • {{platform}}
  • {{#constraints}}
  • {{constraints}}
  • {{/constraints}}
  • {{> output/uncertainty}}

分类与标签

编程开发、无服务器架构、事件驱动、云端部署、故障处理、云成本测算

前往 AI 图片创作