Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

备稿计划: 阿里云函数计算与 Cloudflare Workers 费用对比 #139

Open
iugo opened this issue Sep 30, 2024 · 0 comments
Open

备稿计划: 阿里云函数计算与 Cloudflare Workers 费用对比 #139

iugo opened this issue Sep 30, 2024 · 0 comments

Comments

@iugo
Copy link
Member

iugo commented Sep 30, 2024

阿里云函数计算与 Cloudflare Workers 费用对比

阿里云函数计算计费项

官方文档:
https://help.aliyun.com/zh/functioncompute/fc-3-0/product-overview/pay-as-you-go-billing-method-1

计费项 单位 CU转换系数
函数调用次数 CU/万次 75
活跃vCPU使用量 CU/vCPU*秒 1
闲置vCPU使用量 CU/vCPU*秒 0
内存使用量 CU/GB*秒 0.15
磁盘使用量 CU/GB*秒 0.05
Tesla系列活跃GPU使用量 CU/GB*秒 2.1
Tesla系列闲置GPU使用量 CU/GB*秒 0.5
Ada系列活跃GPU使用量 CU/GB*秒 1.5
Ada系列闲置GPU使用量 CU/GB*秒 0.25

CU 的单价为: 0.00012元/CU

另外针对流量收费为: CDT, 0.8 元/GB.

说明:

  1. 磁盘 512 MB 以内免费, 超出的部分计费.
  2. 中国大陆在 0:00 ~ 6:00 期间, 所有 CU 半价.
  3. 闲置 vCPU 不产生费用.
  4. 闲置内存产生费用.
  5. 目前针对 CU 存在一年的 8 折折扣, 到 2025 年 08 月 27 日.

阿里云收费示例

假设一个 1vCPU 1GB 内存的函数, 每次调用平均耗时 1s, 每月调用百万次, 每月流量 20GB.
调用的时间基本都在白天而不是凌晨, 并且没有使用额外的磁盘.

每月总费用为? AI 计算如下:

让我们来详细计算一下:

  1. 函数调用次数:
    100万次 = 100 * 75 CU = 7,500 CU

  2. 活跃vCPU使用量:
    100万秒 * 1 CU/秒 = 1,000,000 CU

  3. 内存使用量:
    100万秒 * 1GB * 0.15 CU/(GB*秒) = 150,000 CU

  4. 磁盘使用量:
    512MB以内免费,不产生额外费用

  5. 流量费用:
    20GB * 0.8元/GB = 16元

总CU: 7,500 + 1,000,000 + 150,000 = 1,157,500 CU

根据前面提到的官方文档,1 CU = 0.00012元

CU费用 (考虑8折优惠): 1,157,500 * 0.00012 * 0.8 = 111.12元

总费用 = CU费用 + 流量费用 = 111.12元 + 16元 = 127.12元

因此,每月总费用约为127.12元人民币。

注意:这是一个粗略估计,实际费用可能因具体使用情况和价格变动而有所不同。
建议参考阿里云官方的计价器获得更精确的估算。

Cloudflare Workers 计费项

官方文档: https://developers.cloudflare.com/workers/platform/pricing/

计费项 单位 价格
请求次数 百万次 $0.30
CPU 时间 百万毫秒 $0.02

说明:

  1. 每月 5 USD 包含 30 单位 CPU 时间. 价值 0.6 USD.
  2. 每月 5 USD 包含 10 单位请求次数. 价值 3 USD.
  3. 没有流量费.

Cloudflare Workers 收费示例

假设一个函数每次调用平均耗时 1s, 每月调用百万次, 每月流量 20GB.

每月总费用为? AI 计算如下:

让我们来计算一下:

  1. 请求次数费用: 1百万次 = $0.30
    (已包含在每月 5 USD 中)

  2. 数据传输费用: $0
    (Cloudflare Workers 不收取额外的数据传输费用)

  3. CPU 时间费用:
    总CPU时间 = 1百万 * 1秒 = 10亿毫秒 = 1000百万毫秒
    1000 * $0.02 = $20.00
    (30单位已包含在每月 5 USD 中,剩余 970 单位需要额外付费)
    额外CPU时间费用 = 970 * $0.02 = $19.40

总费用 = 基础费用 + 额外CPU时间费用
= $5.00 + $19.40
= $24.40

因此,每月总费用约为 24.40 美元(约合 178.12 元人民币,按 1 美元 = 7.3 元人民币计算)。

注意:这是一个粗略估计,实际费用可能因具体使用情况和价格变动而有所不同。
建议参考 Cloudflare 官方的计价器获得更精确的估算。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant