# 将文件保存在 S3 上的优势是什么？

**URL:** <https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297>\
**Category:** Self-hosting\
**Tags:** s3\
**Created:** [2020年三月23日 20:28 UTC](https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297 "2020-03-23T20:28:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)\
**Post date:** [2020年三月23日 20:28 UTC](https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297/1 "2020-03-23T20:28:27Z")

</div>

我就是这样理解的，我自己也在迁移过程中遇到了问题。我看到很多潜在的问题（也许已经解决了）。因此我想知道——将上传内容保留在 S3 上有什么意义呢？除了节省成本之外，还有其他好处吗？

无论如何，这些节省只有在有人运营一个规模非常大的论坛，并拥有大量文件和图片的情况下才可能实现。或者，也许还有其他优势？

---

<div class="post-metadata">

**Author:** ![maiki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maiki/32/233950_2.png) [@maiki](https://meta.discourse.org/u/maiki)\
**Post date:** [2020年三月23日 22:59 UTC](https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297/2 "2020-03-23T22:59:09Z")

</div>

我将文件托管在 DigitalOcean Spaces（兼容 S3），价格非常实惠，而且无需担心存储问题，这种组合让我很满意。

当有人分享图片，而我们中的一群人想要加载它、评论并分享自己的照片时，我喜欢将其推送到 CDN 并从那里提供内容，让服务器仅向浏览器发送文本。虽然我的社区规模不大，但这种工作流程对其大有裨益；我在大多数地方都采用同样的策略（博客、维基、聊天，几乎任何允许上传内容的地方）。🙂

---

<div class="post-metadata">

**Author:** ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)\
**Post date:** [2020年三月23日 23:26 UTC](https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297/3 "2020-03-23T23:26:26Z")

</div>

出于好奇，如果您能提供这些数据，请问您的平均页面浏览量是多少？上传文件占用了多少 GB 的存储空间？每月的 S3 费用是多少？

---

<div class="post-metadata">

**Author:** ![maiki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maiki/32/233950_2.png) [@maiki](https://meta.discourse.org/u/maiki)\
**Post date:** [2020年三月24日 19:16 UTC](https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297/4 "2020-03-24T19:16:48Z")

</div>

> [@Canapin](#):
>
> 平均页面浏览量是多少？

来自 `admin/reports/page_view_total_reqs`：

> **摘要**
>
> - 2020 年 2 月 23 日 428
> - 2020 年 2 月 24 日 620
> - 2020 年 2 月 25 日 700
> - 2020 年 2 月 26 日 718
> - 2020 年 2 月 27 日 722
> - 2020 年 2 月 28 日 685
> - 2020 年 2 月 29 日 344
> - 2020 年 3 月 1 日 215
> - 2020 年 3 月 2 日 425
> - 2020 年 3 月 3 日 1036
> - 2020 年 3 月 4 日 707
> - 2020 年 3 月 5 日 800
> - 2020 年 3 月 6 日 356
> - 2020 年 3 月 7 日 463
> - 2020 年 3 月 8 日 1859
> - 2020 年 3 月 9 日 678
> - 2020 年 3 月 10 日 620
> - 2020 年 3 月 11 日 677
> - 2020 年 3 月 12 日 519
> - 2020 年 3 月 13 日 615
> - 2020 年 3 月 14 日 423
> - 2020 年 3 月 15 日 513
> - 2020 年 3 月 16 日 512
> - 2020 年 3 月 17 日 508
> - 2020 年 3 月 18 日 551
> - 2020 年 3 月 19 日 507
> - 2020 年 3 月 20 日 531
> - 2020 年 3 月 21 日 1725
> - 2020 年 3 月 22 日 5426
> - 2020 年 3 月 23 日 1293
> - 2020 年 3 月 24 日 294  
> 样本总计  
> — 25.5k  
> 历史总计  
> — 701k

[page-view-total-reqs-200324-190518-7.csv.zip|附件](https://meta.discourse.org/uploads/short-url/hDx4Dg9Tol2ZtTyT7zyw4wGSrkb.zip) (342 字节)

> [@Canapin](#):
>
> 上传的文件占用了多少 GB？

1.4 GB / 3484 个项目

> [@Canapin](#):
>
> 那么 S3 每月费用是多少？

> Spaces 订阅  
> 4.14 美元

这是因为它是按每月 5 美元对应 250 GB 的费率按比例计算的。我在工作中大量使用这项服务，但相比之下，我友好的论坛所消耗的费用几乎可以忽略不计。🙂

我还为市政府和县政府搭建活动网站，允许市民上传图片并将其标记在地图上，甚至进行二次创作。我使用 Spaces 作为上传资源的后端存储，价格非常实惠。如果您对该费用有具体顾虑，请随时告诉我。

---

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [2020年三月25日 03:52 UTC](https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297/5 "2020-03-25T03:52:40Z")

</div>

> [@maiki](#):
>
> 来自 `admin/reports/page_view_total_reqs`：

> [@maiki](#):
>
> 1.4 GB / 3484 项

将论坛文件保留在 S3 上对你来说几乎没有优势。这完全在 VPS 的负载能力范围内。

在你第三次磁盘空间耗尽之前，不必为此担心。

---

<div class="post-metadata">

**Author:** ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)\
**Post date:** [2020年三月25日 12:04 UTC](https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297/6 "2020-03-25T12:04:01Z")

</div>

我得承认，我这边负载也不高。我的流量几乎可以忽略不计，文件也很少。但考虑到未来可能遇到的问题，我原本打算立刻配置 CDN。不过现在看来，这样做带来的问题恐怕会比好处更多……

关于相关问题的帖子实在太多了，而我在执行以下简单命令时也遇到了问题：

> DISCOURSE\_S3\_BUCKET=yy   
> DISCOURSE\_S3\_REGION=eu\_west\_2   
> DISCOURSE\_S3\_ACCESS\_KEY\_ID=yy   
> DISCOURSE\_S3\_SECRET\_ACCESS\_KEY=yy   
> rake uploads:migrate\_to\_s3

我本想将所有文件集中管理，以避免未来的麻烦。但不幸的是，由于相关错误层出不穷，我越来越担心：走得越深，风险越大。

---

<div class="post-metadata">

**Author:** ![maiki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maiki/32/233950_2.png) [@maiki](https://meta.discourse.org/u/maiki)\
**Post date:** [2020年三月25日 21:13 UTC](https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297/7 "2020-03-25T21:13:11Z")

</div>

> [@riking](#):
>
> 你把论坛文件保存在 S3 上对你来说几乎没有优势。这完全在 VPS 的负载能力范围内。

我觉得你是在直接对我说话，但你的建议并不是_针对_我的，所以我不确定该如何回应。

---

<div class="post-metadata">

**Author:** ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)\
**Post date:** [2020年三月25日 22:07 UTC](https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297/8 "2020-03-25T22:07:39Z")

</div>

> [@riking](#):
>
> 将论坛文件保留在 S3 上对你来说几乎没有优势。这在 VPS 的负载能力范围内。

假设相反的情况。文件托管在 S3 + CDN 上。这样会不会更慢？

---

<div class="post-metadata">

**Author:** ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)\
**Post date:** [2020年三月25日 22:10 UTC](https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297/10 "2020-03-25T22:10:44Z")

</div>

我认为这是一个合理的观察：你每年多付 50 美元，只是为了获得你的 VPS 本身就能处理的功能。这增加了额外的故障层和成本，但目前对你来说并没有真正的技术优势。

这些支持话题并不总是为了教育提问者。没必要感到被冒犯，大家在这里都在学习。

---

<div class="post-metadata">

**Author:** ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)\
**Post date:** [2020年三月26日 15:26 UTC](https://meta.discourse.org/t/what-is-the-advantage-of-keeping-files-on-s3/145297/11 "2020-03-26T15:26:43Z")

</div>

所以我的理解是，先使用 VPS，然后可能再迁移到 S3？

假设我目前有 60 GB 空间，如果已使用 55 GB，是否只需更改文件的存储位置，而无需移动旧文件？
