Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node js common practices

Tags:

node.js

I've been reading up on a few node tutorials but there are a couple of best/common practices that I would like to ask about for those out there that have built real node apps before.

  1. Who do you run the node application as on your linux box? None of the tutorials I've read mention anything about adding a node user and group so I'm curious if it's because they just neglect to mention it or because they do something else.
  2. Where do you keep your projects? '/home/'? '/var/'?
  3. Do you typically put something in front of your node app? Such as nginx or haproxy?
  4. Do you run other resources, such as storage(redis, mongo, mysql, ...), mq, etc..., on the same machine or separate machines?
like image 388
paul smith Avatar asked Nov 04 '22 23:11

paul smith


1 Answers

I am guessing this question is mostly about setting up your online server and not your local development machine.

  1. In the irc channel somebody answered the same question and said that he uses a separate user for each application. So I am guessing that this is a good common practice.

  2. I mostly do /home/user/apps

  3. I see a lot of nginx examples so I am guessing that is what most people use. I have a server with varnish in front of the a node.js application and that works well and was easy to setup. There are some pure node.js solutions but for something as important as your reversed proxy I would go for something that is a little more battle-tested.

  4. To answer this correctly you probably have to ask your self. What are my resources? Can I afford many small servers? How important is your application? Will you lose money if your app goes down?

    If you run a full stack on lets say one VPS then if there is a problem with that VPS then only one of your apps is affected.

    In terms of maintenance having for example one database server for multiple apps might seem attractive. You could reason that if you need to update your database to patch a security hole you only need to do it in one place. On the other hand you now have a single point of failure for all the apps depending on that database server.

    I personally went for many full stack server and I am learning how to automate deployment and maintenance. Tools like Puppet and Chef seem to be really helpful for this.

I only owned my own Linux servers for the last 3 months and have been a Linux user for 1.5 years. So before setting up a server park based on these answers make sure you do some additional research.

like image 52
Pickels Avatar answered Nov 11 '22 06:11

Pickels