How to handle Heroku idle? - node.js

I have an issue where heroku apps goes idle every 2mins, which makes the user wait a few minutes to get a payment request. Is there a way to solve this issue? Also what are some good alternatives to heroku? I'm also seeing low scores on Google Page Insights and I'm guessing that's because heroku is idle most of the time. My app is built in nodejs and react

There are many different deployment solutions available; It really depends what kind of functionality is important to you as a developer. There are other Heroku-esque solutions, such as Netlify who over CD as well as Git integration. Any cloud provider will also be able to do a good job of hosting your application at a low cost. I personally, use Amazon Web Services, but Google Cloud, and Microsoft Azure will do an equally good job.
You can deploy your Node/React app to an AWS EC2 instance, as long as you're reasonably proficient at Linux system configuration, and it will be extremely low cost and very fast.

Related

Hosting NodeJS noSQL website

I'm just starting to learn more about the Node.js paradigm and finding it hard to grasp basic concepts. I'm familiar with front-end tools (HTML, CSS, JS) and have been using PHP with Apache server and mySQL db to deploy websites until now.
It seems to be that node is it's own server, and I would then need a SaaS platform like Heroku, or AWS (I'm not even sure if i'm understanding the purpose of these) if someone could explain the difference?
Is the database managed inside this service?
Is the website being hosted there?
In steps how would you get the node app to be served onto your domain name?
For Scalability purposes I understand how having dedicated big infrastructure can help, but if building a low traffic website with small number of members is there even a point in using node?
normal hosting services cost between $4-20 usd. per month and AWS or Heroku seem to start at a MUCH higher price. Is Node only to be used for large scale scaling business model?
Thank you for any answers or good recent external resources (websites or books) you could point me to.
You could easily host a low traffic website built with node.js absolutely for free on Heroku.
To see how easy that is, just go through the Getting Started With Node.js Heroku tutorial, in which you will do just that.
When you build your website with node.js, your own code that your write is the web server. You have no separate web server to configure and interact with (such as Apache). So what you see (or code...) is exactly what you get.
You will probably want to use a framework such as Express to build your web server functionality in your node.js app.
As for NoSQL databases, the way to do this on Heroku is to use an appropriate "add-on" from the Heroku Elements Marketplace. For example, you could easily add Heroku Redis or MongoLab. These are just some of the NoSQL "Database as a Service" options. That means that the Database is itself hosted somewhere in the cloud, and your app simply interacts with it. You don't need to worry about database maintenance, security upgrades etc. You just need to concentrate on your app's interaction with the DB.
Almost all add-ons in the Heroku Elements Marketplace feature a free-tier, that may suffice for your needs, at least initially. So you might be able to get your low-traffic website (including the DB) up and running completely for free, at least initially.
One thing you will need to understand is how Heroku free dyno hours work.
If you need your website to be continuously available 24/7, you may need to verify your Heroku account with a credit card (even though no charges would be incurred as long as you deploy only 1 free web dyno and are on a free-tier plan of your NoSQL DB as a Service). For further details, see this answer.
You also need to consider whether you can tolerate dyno sleeping in your low-traffic app. If not, you would need to prevent your web app from sleeping, which can also be done completely for free. For tips on how to do that see here.
As for serving your Heroku node.js app website from your own domain name, see here. Note that for this too you will need to verify your Heroku account with a credit card, although this too does not incur any charges.
Node.js is supported by many web hosting already, especially for those who use Plesk or cPanel as their web hosting control panel. Here is guide about how to setup a Node.js website via Plesk control, https://www.bisend.com/blog/how-to-set-up-a-node-js-site-in-plesk. As you said, it's very easy to host your website with a cheap shared web hosting.

Google App Engine - Front and Backend Web Development

I currently manage a cluster of VMs on a number of dedicated hosts to provide apache, nginx and node live and development servers. This of course requires constant and time consuming maintenance to ensure security and reliability. I've found more time is spent looking after this platform then coding new and exciting projects. So I've been looking into the Google App Engine to remove the need of managing any VMs but I'm struggling to work out how to get it to function for me!
Currently I find myself developing mostly in Angular (v4-5) for my frontend and nodejs for backend. My development nginx server powers my angular apps and routing to ng-serve and to a separate vm that runs my node apps. I use PM2 to manage the apps on both servers.
This works great! I can code locally push my changes via an rsync script to the servers, the app restarts and changes updated. More importantly, I can affectively code between the front and backend! When ready I can comfortably switch the code to the live servers with little effort - nice!
This is where I am struggling...
I can't seem to work how I would develop and publish versions of both the front and backend code in one App Engine project.
Is this possible? How would I go about deploying/publishing both aspects?
Would I be better having two projects such as example.com & api.example.com? If so, can I get the two projects to talk to one another when developing?
I have and can create a angular/nodejs app in the App Engine but I can't work the basics of front and backend development in this managed service.
I'd like to use the great features of the App Engine such as versioning, easy scaling and importantly deployment of apps and updates. Also, to move all my websites including some older ones in PHP to the App Engine.
Any help surrounding this would be much appreciated. Thanks!
As #Yandrak3 suggested, a microservices architecture is what you need. But keep in mind that that document relates to the App Engine Standard environment which does not support Node.js as a runtime environment. But keep the microservices architecture in mind when deploying to App Engine Flexible.
On backend and frontend
Frontend and backend are no longer used to describe the presentation layer and the data access layer of an App Engine application. The only reference in the documentation is here. The (VM) instances managing a service of your app which are configured with automatic scaling are considered part of the frontend infrastructure, while the ones configured with manual scaling are considered backend infrastructure.
The reason for this is that automatic scaling is one of App Engine's
great features [...] easy scaling,
automatically presenting your app's frontend in a manner scaled with the number of external requests incoming to your app.
Manual scaling is more suited for backend operations, where you might want to run operations dependant on the state of the memory over time, or other scenarios. You can find some more information on scaling types here. Keep in mind that this latter document is under App Engine Standard documentation and it includes basic scaling, a feature not available in the App Engine Flexible environment.
On services and versioning
In your case, your frontend and backend modules of your application will become two separate services in App Engine Flex. For each service you can deploy multiple versions. More, explained here.
Communication between services, in this case between your frontend and backend, can be done through HTTP requests between them.
If the next question is how HTTP requests from users reach the appropriate version of a service (or a service), check this document.
To deploy multiple services, you will use the same commands and you will separate each deployment and service through their afferent configuration file, app.yaml.
Your question requires a response with a pretty wide (and deep) spectrum of concepts. Hopefully, this answer is good to start with.

deploy node.js app to an actual www.mywebsite.com website

Here's a noob question. I made a small app in node.js and to see it I have to go to localhost:4000 in my web browser. How can I publish it in an actual website that everybody can see? I already have a domain name and a hosting service.
Thanks in advance
Your hosting service may not actually support Node. If it doesn't let you install and run your own software then you may be out of luck.
Generally you have few options:
You can host it yourself on your own machine but it will not be as easy and efficient as using a service for hosting, unless you have a high quality symmetric internet connection with low latency and high bandwidth.
You can host it cheaply on a VPS using Digital Ocean, Vultr or AWS in which case you will have to configure Node yourself and install all of the databases and other software that you need.
Or you can use managed platforms like Heroku for Node (and Compose for databse like Mongo that you will probably also need) in which case the price will be higher but everything will be taken care of for you.
It depends on what costs are you willing to take, both in terms of service fees and your time and expertise needed to configure and maintain different layers of the system.
IMO the simplest way to deploy a Node app is with Heroku. You can find the documentation here.
It's free, and basically just requires that you create an app and then push your code to Heroku. It takes care of the rest for you!

How to host nodejs application with sockect.io

I have build an chat application using nodejs with mysql database. I have developed on my windows system and it works fine.
Now I want to make it live on a server to check its real time performance, As a beginner I don't know which server hosting should I choose to develop nodejs application, so someone please suggest me a hosting for nodejs application?
If you want something relatively easy to test on, Heroku will provide you with a free instance.
I can also recommend Azure over Amazon for a simple nodejs based app. The main reason is that Azure has a very simplified interface for deploying node apps after a little bit of minor setup. Amazon offers similar capabilities, but the last time I looked at them they aren't quite as simple to get up and running. Again, they're competitive in cost and reliability, this is just a subjective opinion on what I think will be easier for a dev to get up and running without prior experience.
I use Dokku, an open source solution for a Heroku like PaaS. Either of those are great for doing git style deployments. Heroku has better documentation, and doesn't require your own server so I would start with them.
https://www.heroku.com
http://dokku.viewdocs.io/dokku

Easiest server and database services available for deploying an application (AWS specifically)

I have written a real-time multiplayer game and currently writing its server in NodeJS. I want my game to have login, level up etc, so I need to have a database. This is the first time I am deploying something and I am mostly self taught, so please correct me if I am mixing things up. Since this is my first trial, I do not want to make much commitment right away so I am looking for free options only. And since this should be a real-time game, I need a relatively fast server response. That is why I am looking for the easiest database and server provider that would do and I am aware that with those restrictions I have limited choices and functionality.
As far as I have read online, Heroku seems to be my simplest option for a server (that is why I started writing in NodeJS). However it seems like there is no free database service since all options on https://devcenter.heroku.com/articles/heroku-postgres-plans has monthly fee. I did not want to use Google App Engine since I am new (it certainly is not mentioned as beginner friendly).
So I have found AWS following Free Cloud Database Service for home development post, it seems like I could use Amazon Web Services as a server and database. However most posts I have encountered suggests Google App Engine or Heroku with little mention of AWS. Is this because I am mixing concepts up, or does AWS have drawbacks that I am not aware of? Do you think it is a good idea to use AWS for both as server and database, is it possible to use Heroku as server while using AWS as database or do you have any other suggestion?
Note: Sorry for the question bombardment but those are all related and I am sort of lost in this topic so I had to ask...
Use AWS EC2 for the server and RDS for the database. The reason why people use heroku is that it deploys to a custom url very quickly (it's easy to set up). Setting up AWS requires some knowledge of how servers work, but it's not that complicated (and it's free for small apps). Best of luck!

Resources