Node.js site super slow compared to PHP site

I have my site moved over to Heroku (Node.js) from A2 Hosting (PHP) and it’s super slow - like things take 3x the amount of time to load. Anyone have any ideas on what might be causing this?

Edit: It’s actually the same speed on localhost as Heroku so thinking something about Node.js as opposed to the hosting.

Are you using a remote database?

Yes. The database is MySQL on the A2 hosting still. I did find disabling a repeat significantly improved the speed but not an ideal solution.

The same would happen if you used PHP on Heroku (or any other hosting provider), it’s not related to NodeJS, it’s related to the time it takes for data to go back and forth the remote database.

The reason you don’t experience this delay with A2Hosting on your current PHP website is because the database is very near (if not in the same server).

So, in theory you’d need to host your website closer to the remote database, though I personally think it’s not a very good idea in general to use a remote database.

It looks like Heroku doesn’t natively support MySQL so I’d need to use an add-on or switch to Postgres. Hmmmm.

Doesn’t A2 Hosting supports NodeJS on shared hosting?

If you’re not under any contract migrate to Digital Ocean. Can’t fault their services one bit. Database cluster for $15 a month (includes regular backups and all databases encrypted at rest) and $6.00 a month for a Droplet. Easy to configure and fantastic network speed. Usually they offer between $50 to $100 in credit to new registrations so you’ll get the first few months for FREE in the majority of circumstances. Can’t rate them highly enough.

3 Likes

Or you can use Hetzner Cloud, about $5 or less depending on server location each.

You can create two servers for less $5 each, one for use only as hosting and the other as database server.
Hetzner services as other cloud providers allow creating private network, so, both servers will be on same private network for full network speed connections.

This second server will be more powerfull than DO with 2 vcores, 2GB RAM, 40GB SSD. This option means that you should manage the server yourself, and install everything from scratch.
With DO you get (1 vcore, 1 gb RAM, $15/m) but this is managed-databases, means that you don’t have to worry about anything else more than create databases.

If manage server is not your, you can use DO or Hetzner and install CloudPanel, it works for nodeJS and comes with mysql or mariadb installed, in this case you just need to import the backup of your database into the phpmyadmin that comes inside CloudPanel.

2 Likes

They do, but they only support web sockets on managed VPS and dedicated servers. Looking at it now, that’s $24.99/month. Not too bad really. Might think about doing that.

Thanks. Will have a look.

I can confirm. Excellent service, reliable and very easy

1 Like