简体   繁体   English

推荐的Node.js Azure网站设置

[英]Recommended Node.js Azure Website setup

I'm currently building a small Node.js Website and I want to host it on Azure. 我目前正在建立一个小型的Node.js网站,并希望将其托管在Azure上。 I wanted to ask whether I should separate the Front- and Backend parts of the app into two different Azure Websites, or just put the whole app into one Azure Website slot. 我想问我是否应该将应用程序的前端和后端部分分成两个不同的Azure网站,还是将整个应用程序放在一个Azure网站插槽中。

The reason I think separating into two parts might make sense is because I want to access the Backend part not only from the corresponding website but also from other parts (eg a mobile app). 我认为将两部分分开可能是有道理的,因为我不仅要从相应的网站而且还要从其他部分(例如,移动应用程序)访问Backend部分。 And I think that in this setup updating the Frontend part would also mean downtime for the Backend API. 而且我认为,在此设置中,更新前端部分也将意味着后端API停机。

On the other hand, two websites make it harder to query the Backend from the Frontend (hardcoded URLs, socket.io can't just easily be setup anymore, etc.) 另一方面,两个网站使从前端查询后端变得更加困难(硬编码的URL,socket.io不能再轻易设置了,等等)。

What would you recommnd in my case? 在我的情况下,您会提出什么建议?

Thanks a lot. 非常感谢。

ExpressJS Socket.io some Database jquery on client / cheerio on serverSide (DOM parsing) ExpressJS Socket.io客户端上的一些数据库jquery / serverSide上的cheerio(DOM解析)

Don't have any experience with Azure.. Switch to Linux!! 没有Azure的经验。切换到Linux! Have access to your apps, data, should be very important and one of things the app is built around.. 拥有访问您的应用程序,数据的权限非常重要,这是应用程序构建的基础之一。

Azure websites supports creating staged deployments for you site http://azure.microsoft.com/en-us/documentation/articles/web-sites-staged-publishing/ Azure网站支持为您的网站创建分阶段部署,网址为http://azure.microsoft.com/zh-cn/documentation/articles/web-sites-staged-publishing/

This means that you don't need to worry about downtime for your backend when you're updating your front end, since you can update the front end in the staging environment, then when it's ready to be deployed you just swap the staging and production environments and all requests get immediately redirected to the updated version of your site with no downtime. 这意味着您在更新前端时无需担心后端的停机时间,因为您可以在登台环境中更新前端,然后在准备好部署时只需交换登台和生产即可环境和所有请求都会立即重定向到您网站的更新版本,而无需停机。

Zain is correct in that you can create slots in your Azure website and swap them to prevent downtime. Zain是正确的,因为您可以在Azure网站中创建插槽并进行交换以防止停机。 For example, you can create a staging slot and a production slot and push your updates to staging. 例如,您可以创建一个暂存插槽和一个生产插槽,并将更新推送到暂存。 Once satisfied that staging is working correctly, you can swap staging with live and in theory there should be no down time at all for the live slot. 一旦确信分段正常运行,就可以将分段与实时交换,理论上,实时插槽应该完全没有停机时间

That said, it depends on your budget. 也就是说,这取决于您的预算。 An Azure app with slots costs more than one without. 没有插槽的Azure应用的成本不止一个。 If you want cheap and don't care about things like custom domains, use two free websites and that will solve your problem. 如果您想便宜而又不关心自定义域之类的东西,请使用两个免费网站,这将解决您的问题。 Otherwise, and to keep everything together, I would probably just combine them and pay the higher price, but it depends on how your app works too. 否则,为了使所有内容组合在一起,我可能会合并它们并支付更高的价格,但这取决于您的应用程序也如何工作。

If price isn't an issue, I would ask myself: "How difficult is it going to be to query the back end from the front end?" 如果价格不是问题,我会问自己:“从前端查询后端有多困难?” If it's going to be a pain and make what would be a simple app overly complex, you might want to combine the apps and use deloyment slots (see here for more info: https://azure.microsoft.com/en-us/documentation/articles/web-sites-staged-publishing/ ) 如果这会很痛苦,并且会使一个简单的应用程序变得过于复杂,则您可能需要组合这些应用程序并使用部署插槽(有关更多信息,请参见此处: https ://azure.microsoft.com/zh-cn/ 文档/文章/网站分阶段发布/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM