[英]Are heroku servers slow?
I have a node js webiste, when I run it on localhost on my computer, it runs blazingly fast but when I deploy it on heroku, it becomes very slow.我有一个 node js webiste,当我在我的计算机上的 localhost 上运行它时,它运行得非常快,但是当我将它部署到 heroku 上时,它变得非常慢。 So will this also happen if I host my site with digital ocean or any other hosting provider?
那么,如果我使用数字海洋或任何其他托管服务提供商托管我的网站,也会发生这种情况吗?
This is my package.json这是我的 package.json
{
"name": "something",
"version": "1.0.0",
"engines": {
"node": "16.x"
},
"description": "",
"main": "app.js",
"scripts": {
"start": "cross-env NODE_ENV=production node app",
"dev": "cross-env NODE_ENV=development nodemon app"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"compression": "^1.7.4",
"connect-mongo": "^4.6.0",
"cross-env": "^7.0.3",
"cryptr": "^6.0.3",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"express-handlebars": "^6.0.5",
"express-session": "^1.17.2",
"flatted": "^3.2.5",
"got": "^12.1.0",
"lodash": "^4.17.21",
"method-override": "^3.0.0",
"moment": "^2.29.3",
"mongoose": "^6.3.1",
"most-common-words-by-language": "^3.0.10",
"node-fetch": "^3.2.4",
"passport": "^0.5.2",
"passport-google-oauth20": "^2.0.0",
"randomcolor": "^0.6.2",
"request": "^2.88.2",
"workbox-cli": "^6.5.3"
}
}
It is most likely not a hosting provider issue but rather a limitation issue.这很可能不是托管服务提供商问题,而是限制问题。
Heroku uses the Linux containers Dynos to execute your code in their platform, and they have multiple types with differentiating characteristics. Heroku 使用 Linux 容器Dynos在其平台上执行您的代码,它们具有多种类型,具有不同的特征。 If you have an unverified account, then you're given the
free
dyno type by default.如果您有一个未经验证的帐户,那么默认情况下您将获得
free
的 dyno 类型。 Check Heroku's dynos page.检查 Heroku 的dynos页面。 You'll see that for the " Always on " row, the
free
type has the trait:您会看到对于“始终在线”行,
free
类型具有以下特征:
"Sleeps after 30 mins of inactivity, otherwise always on depending on your remaining monthly free dyno hours."
“闲置 30 分钟后睡觉,否则总是取决于你每月剩余的免费测功时间。”
This is your issue.这是你的问题。 Your app starts slower when the dynos are asleep.
当测功机睡着时,您的应用程序启动速度会变慢。 The speed improves as you continue using the app, but it's not going to be performant and it's going to start slow again once the app is inactive for 30 mins.
随着您继续使用该应用程序,速度会提高,但它不会表现出色,并且一旦应用程序处于非活动状态 30 分钟,它就会再次开始变慢。 If you want your app to be blazingly fast in Heroku, then you need to verify your account and purchase a non
free
or hobby
dyno type.如果您希望您的应用程序在 Heroku 中快速运行,那么您需要验证您的帐户并购买非
free
或hobby
dyno 类型。
Take note that you will also face similar issues with other hosting providers if you are using free account on their platform.请注意,如果您在其他托管服务提供商的平台上使用免费帐户,您也将面临类似的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.