Host my own node.js webapp or deploy using a hosting service - node.js

I have a web app that's like a bulletin board where users upload their images and such. Is it best if I host this web app on my own hardware or use a hosting site?
The reason why I'm considering my own hardware is because it's my hardware which will be simple to me and something I know best, also I'll have file system access and see what the users are uploading, most hosting sites don't offer that .

You might want to base your choice depending on what's your favourite operating system for servers. If it's on window, I would recommend self hosting as most VPS with window cost way more than linux server. Overall, depending on the resources you need, the average cost of a linux server in the cloud is around 2.50 ~ 10.00 per months and with that you have a guaranteed fix IP address.
Soooo the question is, is all the trouble of setting up your server + maintaining it + managing a fixed IP with your ISP (plus ISP charges *) worth at worst 10 box per month? Your choice!
here is a few services you might want to consider for VPS
https://aws.amazon.com/
https://www.digitalocean.com/
https://www.heroku.com/ (this one have free hosting if you don't mind the 24/7 uptime)
and there is so many others.
As an example, my ISP charge around 100 CAD more per month just to consider my IP static and have a commercial profile for my internet.

You can host on VPS. It can have any operation system you want. And you control it. It is much cheaper that dedicated hosting on your hardware.
http://www.google.com/search?q=vps
If you want to host node. You have to install manually, NodeJS, and the required NPM modules.

Related

What is the best architecture for a web-app communicating with a gRPC service?

I have built a website with chess.js and java chess libraries that communicates with a custom c++ chess engine via gRPC with python. I am new to web dev and especially gRPC, so I am not sure on the architecture I should be going for when it comes to hosting.
My questions are below:
Do the website and gRPC service need to be hosted on separate server instances and connected via API?
Everything right now is hosted locally and I use two ports as it is right now (5000 for the website and 8080 for the server). If the site and server aren't separate, is this how they will communicate to each other on a single server (one local port)?
I am using this website just for a showcase of my portfolio for job searching, so I am looking for free/cheap hosting that also provides a decent RAM availability since the c++ chess engine is fairly computationally intense. Does anyone have any suggestions for what hosting service I should use for this?
I was considering a free hosting for the website and then a cheap dedicated server for the service (if the two should be separate). Is this a bad idea?
Taking all tips and tricks that anyone has to offer. Again, totally novice to web dev, hosting, servers, etc.
NOTE This is an architecture rather than a programming question and discouraged on stack overflow.
The website and gRPC service may be hosted on the same server (as you're doing locally). You have the flexibility in running both processes (website and gRPC service) on a single more powerful host or separately on two hosts.
NOTE Although most often gRPC communicates over TCP sockets, it is possible to use UNIX sockets and even buffered memory too.
If you run both processes on a single host, you will want to consider connecting the website to the gRPC service via localhost (127.0.0.1 or the loopback device). Using localhost, network traffic doesn't leave the host.
If you run both processes on different hosts, traffic must travel across a network. This is slower and will likely incur charges when hosted.
You will want to decide whether the gRPC service should be exposed to any network traffic other than your website. In many cases, a gRPC service is used to provide an API to facilitate integration by 3rd-parties. If you definitely don't want the gRPC service accessed by other things, then you'll want to ensure either that it's bound to localhost (see above; and thereby inaccessible to anything other than other processes e.g. your website on the host) or firewalled such that only the website is permitted to send traffic to it.
You can find cheap hosting of virtual machines (VMs) and you'll likely want to consider hosting both processes on a single VM, ensure that you constrain the resources that you pay for and that you secure traffic (as above).
You may wish to consider containerizing the application. In this case, while it's possible to run both processes in a single container, this is considered not good practice. You should thus consider 2 containers (website and gRPC server). Many hosting|cloud platforms provide container hosting and this is generally easier than managing VMs (since you don't need to patch|update the OS and any dependencies). If you can find a platform that accepts a Docker Compose describing or a Kubernetes Deployment in which you describe both your services and how they interact such that the gRPC service is only accessible to the website, that could be ideal.

How to host Node.Js server and PostgreSQL database from my computer?

I want to host my own server and database on my computer, I don't want to pay monthly for services.
I developed a node.js app and it's using a postgresql database. I have a domain with an angular app and the app needs to use data from the server.
Can someone tell me how I can do this and which OS would be the best?
Thanks!
You have to do few things for that to work.
First, your Angular app needs to be able to connect with your home server so it either needs a static IP address accessible from the outside, a dynamic IP with dynamic DNS, or a VPN.
Your server needs to properly support CORS so that your Angular app would be able to connect with it. It will send OPTIONS requests that your server needs to handle properly.
Make sure that your server is always on, the internet connection is reliable, the power is reliable and that your services are properly restarted on reboot.
Make sure that your server is always up to date with security patches, is configured properly and doesn't use any unneeded software and services.
For (1) you have a lot of options and it all depends on whether you have a static or dynamic IP address, whether it is accessible from the internet etc. which you didn't include in your answer.
For (2) it depends on what Node framework do you use for you server-side application which you didn't include in your question. You need to use a way to set up CORS that is specific for the framework that you use.
The (3) is hard in home environment but it's important because on any downtime your users will not be able to use your application.
The (4) is critical in home environment because if anyone breaks into your server, he'll have access to your home network which may have a different kinds of consequences that breaking into a data center.
Another option would be to use a cheap VPS provider like Digital Ocean where you can get a server for $5 a month (or 2 months for free with this link) which may be less hassle that setting up your own server - for which you have to pay for electricity, manage the hardware, monitor the connectivity etc.
If you choose a VPS then (1) us taken care for you - you get your own static IP address accessible from the world, (3) is taken care for you completely, (4) is relatively easy to do and the biggest issue is making sure that CORS works as it should - but here you can host your API on the same domain as your frontend and then you don't need to worry about CORS at all.
If you get a VPS then you can host your frontend Angular app from the same server so that it doesn't even have to cost you more.

Nods js Deployment since all my servers are very old (any alternatives.)

All the servers which i have are windows servers which are very old.
What would be an alternate to deploy the Node js tool which i have developed.
Any free servers on-line or from Local,is it possible to make it available to everyone.
Please help.
When you are developing it's typical to run your Node apps locally on your own computer and use localhost to connect to them. But to make it available to the wider public then you really need to get a server. The cheapest options are Virtual Private Servers. The only free option to have such a server that I know about is Digital Ocean when you register with a coupon link to get 10 usd coupon to use on their servers, which is two months for their cheapest server - which is actually quite nice: 512MB RAM, 20GB SSD disk, and 1000GB monthly transfer. The billing is actually per hour so if you want a server just once in a while for some tests, that 10 usd credit can potentially last you for years. There are no limits on domains that you host and you can choose an operating system from: Ubuntu, Debian, Fedora, CoreOS, CentOS, FreeBSD. You can choose location in New York, San Francisco, Toronto, London, Frankfurt, Singapore, Bangalore and Amsterdam - whatever place is closest to you or your users.

Why node.js can't run on shared hosting? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
First thing: I searched all of the known web hosting companies for shared hosting of nodejs but I didn't find anyone. Then I came to know that nodejs cannot run on a shared host system. I want to know why?
Second thing: I am a normal guy with a normal budget. Choosing a vps or deicated server or cloud hosting makes the node run, but its out of my pocket money range as compared to the PHP shared hosting services, so should I learn node.js?
Theoretically it can, but practically it depends on hosting provider to have such infrastructure in place.
Node comparing to classic web platforms is self-sustainable platform. In case with PHP (for example), it runs on with of apache or nginx (or any other), and PHP it self is just script language with some libraries that does not do much apart of logic implementation, and requires web server solution. Web server creates socket to listen specific ports for traffic, will do its own magic and will execute PHP to process requests.
In meantime node.js creates own socket, and binds it to own port. That gives it much more low-level access, so it is web server it self. You can't bind to one port two applications, so it already unsharable.
There are services (web servers) that allow you to create proxy to route traffic to your node.js process but that is not as efficient in some cases, and shared hosting does not provide such functionality.
As node.js is still fairly young as well as is well, different, it still did not hit majority of shared hosting services. There are some available services online to host your node.js applications in a 'shared' manner.
Additionally you can rent EC2 Micro instance on AWS for free (Free Tier) for one year, which gives you plenty possibilities and time to try and test different stuff. You'll get semi-dedicated system, where you can do pretty much anything (install software, modify OS configurations, and much more), where shared hosting would not allow you to do so.
Look into Heroku. For simple low traffic apps, they are free and can easily be scaled for more traffic (for an added cost). Additionally, you use Git to deploy, so is really simple to get stuff updated...
There are other ways to deploy node.js apps.
You can use PaaS services, like Openshift, Heroku, AppFog, Paastor, dotCloud etc.
Other great node app hosting options include Joyent's SmartOS and Microsoft Azure. Both have a free trial period.
Azure can be a great learning platform for node.js as you can host your node app in Windows Server, Ubuntu Linux, or Azure's special "web site" shared deployment scheme.
http://www.windowsazure.com/en-us/develop/nodejs/tutorials/create-a-website-(mac)/
Another cost efective solution for node app hosting is Azure's "Web Site" approach - about $10 per month. The down side is that you have to use their shared environment that hosts your node app via IIS. In practice, this worked for well for me, but you are limited in that you can't use certain Linux functions from Node when it's running on Windows, and you won't learn how to configure the node service yourself, which may or may not be important to you. (Note: Azure's GIT deployment process works great if you want to deploy your app from a local GIT repository. Also note that NodeIIS will stop your node app when it's not in use for a certain period of time - and it auto-starts again when a request for your app comes in.)
Joyent's SmartOS platform is a Linux OS optimized for hosting your node.js app. They have impressive reliability and performance as well as great diagnostic tools.
http://wiki.joyent.com/wiki/display/jpc2/Developing+a+Node.js+Application
The most cost effective solution I have found so far is DigitalOcean, a great new hosting solution where you can host a full Linux VM for only $5/month! I have had great luck hosting Node apps there so far: https://www.digitalocean.com/pricing
a2hosting allows Node.js in shared hosting.But don't have experience there.Found from a web search
Update : Use DigitalOcean. Private VPS
Node doesn't work like most servers. With IIS and Apache, there is one server running multiple sites, which lends itself to shared environments. With Node, you're running your own server so instead you tend to share resources on a machine.
I can't tell you whether it's worth learning node because I don't know your motivation, but it can expand your career opportunities if you choose to go there, and to expand your skillset.
Here are a couple of hosting options in the low price range.
http://nodester.com/
https://www.nodejitsu.com/

File Server vs NAS for hosting media files

I have a web portal where my users can login and submit artworks (image, documents, etc.). This web portal is hosted in 2 load-balanced web servers.
Because of this load balancing, I'm thinking of using NAS to serve as a centralized media file storage for my web portal. I'm considering NAS because it's cheaper than a file server and it's easier to maintain.
Now the questions are:
File hosting - Is there any NAS device that can act as a file hosting server? Or, do I need to create a virtual path in my web server to the NAS? This can be achieved easily if I use a file server, I can just bind a separate domain to the file server, something like media.mydomain.com, so all media files will be served through this domain. I don't mind serving the media files through a virtual path from my web servers, smthg like mydomain.com/media. I would like to know if NAS can do any of the approaches above, and whether it's secure, easy to setup, etc.
Performance - This is more important because read and writes are quite intensive. I never use NAS before. I'm thinking of getting 2 hard drives (2TB, 15000RPM) configured for RAID-1. Would this be able to match the performance of a common file server? I know the answer to this question is relative but I just want to see how NAS can be used as a file hosting, not just as a file sharing device.
My web servers are running Windows Server 2008R2 with IIS 7.5. I would appreciate if anyone can also share best practices for integrating NAS with Win Server/IIS.
Thanks.
A NAS provides a shared location for information on a private network (at least you shouldn't expose NAS technologies as NFS and CIFS over the internet) and is not really designed as a web file host. That is not to say you can't configure a NAS as a web file host utilizing IIS/apache/nginx, but then you don't need your web servers. NAS setup is well documented for both windows server and most unix/linux distros, both are relatively easy. A NAS is as secure as it is designed to be, you can utilize a variety of access control methods to secure a NAS depending on your implementation.
This really depends on your concurrent users and what kind of load you are expecting them to put on the system, for the most part performance over a 1Gb LAN connection and a 15,000 RPM hard drive for a NAS should provide ample performance for a decent amount of concurrent users, but I can't say for certain because if a user sits there downloading hundreds of files at a time you can have issues. As with any web technology wrap limits around user usage to prevent one user bringing down your entire system. I'm not sure what you are defining a file server (a NAS is a file server), if you think of a file server as a website that hosts files, a NAS will provide the same if not better performance based on where the device is in relation to your web servers (again, depending on utilization). If you are worried about performance you can always build a larger RAID array using RAID 5, RAID 6, RAID 10 or use SSDs to increase storage performance. For the most part in any NAS the hardware constraints usually are: storage speed, network speed, ram, cpu. Again this really depends on utilization, so test well, benchmark, and monitor performance
Microsoft provides a tuning document for server 2008 r2 that is useful: http://msdn.microsoft.com/en-us/library/windows/hardware/gg463392.aspx
In my opinion your architecture would be your 2 web servers referencing the NAS as a shared location using a virtual directory pointed at the NAS for your files or handle the NAS location in code (using code provides a whole plethora of options around security and usage).

Resources