Node.JS Rest API/MySQL [英] Node.JS Rest API / MySQL

查看:82
本文介绍了Node.JS Rest API/MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am running a Node.JS 8.1 Rest API that consumes a MySQL DB on an App Service (S2 Production plan). I have enabled CORS and have connection pools for my DB Connections. Everything is working fine when usage is constant, but when there is no request for more than an hour or two it seems that the service is going Idle and I get a 502 Bad Gateway issue (only for the first, next request are handled OK).

I set the Always On Setting but still I have the issue. Not sure what else to do as I cannot find any more information on how to make that process not go to idle or cold start and be always available. I would like to request your help on this if there is any other setting I need to worry or 'Always On' should do it to or if there is anything else.

推荐答案

Diego,请注意每隔5分钟始终" ping站点根目录.如果站点根目录之外存在依赖关系,这是某些API的问题,那么始终在线"将不会使那些依赖关系保持加载或温暖"状态.

Diego, please note 'always on' ping the root of the site every 5 minutes. If there are dependencies outside of the root of the site, which is the issue for some APIs, 'always on' will not keep those dependencies loaded or 'warm'.

如果没有此功能,您的API可能每隔15-20分钟就会被卸载一次.作为一种解决方法,我建议您考虑使用Application Insight的"Ping URL"功能,因为这将使您选择ping的来源以及频率. 有关更多信息,请检查 这里.

Without this feature, your API is likely being unloaded every ~15-20 minutes. As a workaround, I would suggest looking into using Application Insight's 'Ping URL' feature instead as this will let you select the source of the ping along with the frequency. For more info on that, please check here.


这篇关于Node.JS Rest API/MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆