简体   繁体   中英

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. So will this also happen if I host my site with digital ocean or any other hosting provider?

This is my 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. If you have an unverified account, then you're given the free dyno type by default. Check Heroku's dynos page. You'll see that for the " Always on " row, the free type has the trait:

"Sleeps after 30 mins of inactivity, otherwise always on depending on your remaining monthly free dyno hours."

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. 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.

Take note that you will also face similar issues with other hosting providers if you are using free account on their platform.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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