0

I am running a free tier Heroku app in the cloud using Node.js, alongside a free tier MongoDB cluster. I recently deployed my web server (used by our game for scores submission and retrieval), and it ran fine for the first night. The following day, I played our own game and noticed that the leaderboards were loading extremely slow. Sometimes, it wouldn't load at all. I went to the logs and saw that service times were through the roof, sometimes reaching ~30 sec. I increased the poolSize on the connection but it still ran slow. Today, it has run well with few issues, albeit still riddled with absurdly slow response times, hanging around the ~20 sec area. This feels so random. I looked into mongoose, based off this answer, but according to MongoDB's Node.js driver docs, a single connection is in itself a pool... What could be happening? My client connection is obtained as follows:

var DB = null;
mongodb.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true, poolSize: 70 }, (err, cli) => {
    if (err) {
        console.log("Error connecting to MongoDB Client: " + err);
        return null;
    }
    client = cli;
    DB = client.db(<database>);
});

This is a live server, with a live game depending on it, and timely responses would be greatly appreciated. Thanks for any help I can get.

EDIT: Will switching to mongoose help me in this situation?

kedar sedai
  • 1,687
  • 3
  • 16
  • 25
blizzo
  • 11
  • 6
  • Perhaps this: https://devcenter.heroku.com/articles/free-dyno-hours "If an app has a free web dyno, and that dyno receives no web traffic in a 30-minute period, it will sleep. If a sleeping web dyno receives web traffic, it will become active again after a short delay (assuming your account has free dyno hours available)." – ceejayoz Apr 04 '20 at 03:06
  • If it's not that, you'll have to benchmark things to see where your bottleneck is. – ceejayoz Apr 04 '20 at 03:06
  • 1
    MongoDB free tier is limited to something like 100 connections, and I'm pretty sure has both operation count and bandwidth limits. – Joe Apr 04 '20 at 03:39
  • I dont feel like that is the issue – blizzo Apr 04 '20 at 04:50
  • 1
    @blizzo Doesn't really matter how you *feel*. Test and benchmark so you *know*. – ceejayoz Apr 04 '20 at 15:42
  • @ceejayoz i knew someone would respond like that lol. what is the best way to benchmark? – blizzo Apr 04 '20 at 16:00

0 Answers0