我们在 Azure 中有几个不同的角色。目前,这些都部署到单独的实例中,因此它们可以单独扩展(在生产中这是我们想要的),但是对于测试这似乎很浪费,我们希望能够将所有角色部署到单个实例以最小化成本。
我们可以这样做吗?
我们在 Azure 中有几个不同的角色。目前,这些都部署到单独的实例中,因此它们可以单独扩展(在生产中这是我们想要的),但是对于测试这似乎很浪费,我们希望能够将所有角色部署到单个实例以最小化成本。
我们可以这样做吗?
Roles are essentially definitions for what will run inside a set of Windows Azure VM instances. By definition, they have their own instances, so they cannot be targeted toward a single set of instances.
That said: there's nothing stopping you from combining code from different roles into one single role. You'd need to make sure your OnStart()
and Run()
take care of all needed tasks, as well as combining startup script items.
The upside (which you already surmised): cost savings, especially when running at low volume (where the entire app might be able to run in two instances, vs. several more near-idle instances split up by role).
One potential downside: Everything combined into a single role will now scale together. This may or may not be an issue for you.
Also, think about sizing. Let's say your website is perfectly happy in a Small, yet some background task you have requires XL (maybe it's a renderer needing 10GB RAM or something). And let's say you always run 2 instances of your website, for SLA purposes. Now, even at very low volume, your app consists of two XL instances instead of 2 Small (web) and one XL (background). Now, your near-idle system could cost more as one combined role than as separate roles. This might not apply to you - just giving an example where it might not make sense to combine...
在 David 的精彩解释的基础上,添加东西并通过 OnStart 或 Run 覆盖将它们粘合起来会起作用,但你真的正确地测试了吗?配置值合并在一起,内存使用、并发性等潜在问题。您不会在部署到生产环境时测试相同的产品。
更好的方法是将超小型实例部署到您的 QA 环境中。它们的成本只是中型或大型服务器价格的一小部分,并提供有意义的测试平台。