部署
Deployment
部署 Web 应用程序的方法与开发者一样多,更不用说应用程序本身了。但在部署应用程序时,有几个有用的技巧需要牢记。
There are as many ways to deploy a web application as there are developers, let alone applications. But there are a couple useful tips to keep in mind when deploying an app.
一般建议
General Advice
-
记住:始终部署以
--release模式构建的 Rust 应用,而不是调试(debug)模式。这对性能和二进制大小都有巨大影响。 -
Remember: Always deploy Rust apps built in
--releasemode, not debug mode. This has a huge effect on both performance and binary size. -
也要在 release 模式下进行本地测试。框架在 release 模式下会应用某些在 debug 模式下不应用的优化,因此此时可能会出现一些错误。(如果你的应用行为不同或确实遇到了 bug,这很可能是框架层面的 bug,你应该在 GitHub 上提交包含复现步骤的 issue。)
-
Test locally in release mode as well. The framework applies certain optimizations in release mode that it does not apply in debug mode, so it’s possible for bugs to surface at this point. (If your app behaves differently or you do encounter a bug, it’s likely a framework-level bug and you should open a GitHub issue with a reproduction.)
-
请参阅“优化 WASM 二进制大小”章节,了解更多技巧和方法,以进一步改善 WASM 应用首次加载的可交互时间(Time-to-Interactive)指标。
-
See the chapter on "Optimizing WASM Binary Size" for additional tips and tricks to further improve the time-to-interactive metric for your WASM app on first load.
我们请用户提交他们的部署设置以协助完成本章。我将在下面引用其中的内容,但你可以在这里阅读完整的主题帖。
We asked users to submit their deployment setups to help with this chapter. I’ll quote from them below, but you can read the full thread here.