返回提示词目录第 1185 页

设计媒体上传与异步处理架构

根据媒体类型与业务规模规划上传、队列处理和分发链路,输出架构图及存储运维方案。

完整提示词

<context>
Processing user media is a background job problem with sharp edges. Uploads should go directly to object storage (presigned upload), then an event or queue message triggers processing, so web servers never hold large files. Video transcoding is CPU or GPU heavy and slow; managed transcoding services or adaptive streaming formats are usually cheaper in engineering time than a self-run farm, while images can often be resized on demand at the edge or by an image service with caching. Each job must be idempotent (keyed by the source object and preset), have a timeout, retry transient failures and send poison files to a dead-letter queue. Users need a visible status (uploaded, processing, ready, failed) instead of broken thumbnails. Media files are untrusted input: decoders and document converters have a long history of vulnerabilities, so processing runs in isolated workers with resource limits, validates real file types by content rather than extension, and strips metadata such as GPS location from photos when privacy matters. Storage cost grows forever unless originals and renditions have lifecycle rules. CDN delivery needs cache-friendly URLs, ideally versioned rather than invalidated.
</context>

<task>
<media>
{{media}}
</media>
{{#scale}}
Scale: {{scale}}
{{/scale}}
{{#constraints}}
Constraints: {{constraints}}
{{/constraints}}

1. Estimate volume: uploads per day, storage added per month for originals and renditions, and processing minutes per day. Label assumptions.
2. Decide per media type between a managed service, on-demand processing at request time with caching, or self-run workers, and explain the choice.
3. Define the upload path: presigned direct upload, size limits, content-type validation by magic bytes, and a database record created before processing.
4. Define the pipeline: storage event or message, queue, worker per job type, idempotency key, timeouts, retries with backoff, dead-letter handling, and status updates.
5. List renditions with formats and sizes, and say which are eager and which are on demand.
6. Define storage layout, lifecycle rules (infrequent-access tier, deleting abandoned uploads), private versus public objects, signed URLs and CDN caching with versioned URLs.
7. Cover isolation of processing workers, metadata stripping, and where malware scanning or content moderation hooks in if required.
</task>

<constraints>
- Do not route large files through application servers.
- Treat every uploaded file as untrusted; never run converters in the web process.
- Do not quote service prices or limits as facts; name what to check and the unit cost to measure.
- Keep the design proportional to the stated volume.
{{> output/uncertainty}}
</constraints>

<output_format>
## Recommendation
Managed service, self-run workers or a mix, in at most five lines.
## Pipeline
A Mermaid flowchart from upload to delivered rendition, then one line per stage.
## Renditions
Table: output, format, size or bitrate, when generated (eager or on demand).
## Jobs and status
Queue, idempotency, retries, timeouts, status model visible to the user.
## Storage and delivery
Buckets or prefixes, lifecycle tiers, signed URLs, CDN caching and invalidation.
## Security and safety
Validation, untrusted file handling, malware and moderation hooks.
## Cost drivers
What dominates cost and how to measure it.
</output_format>

可替换内容

  • {{media}}
  • {{#scale}}
  • {{scale}}
  • {{/scale}}
  • {{#constraints}}
  • {{constraints}}
  • {{/constraints}}
  • {{> output/uncertainty}}

分类与标签

编程开发、媒体处理、异步任务、对象存储、架构设计

前往 AI 图片创作