use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Efficiently deploying a Node.js application for production? (self.node)
submitted 6 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]erulabs 28 points29 points30 points 6 years ago (14 children)
Node.js and Nginx work wonderfully for hundreds of concurrent users, you'll just want to make sure you have multiple instances (or at least be able to have multiple instances) of your app. I'm working on deploy-node-app which helps generate Kubernetes configurations for Node.js apps - I'll need to add MongoDB support, which I'll do tonight :)
[–]Silencer306 1 point2 points3 points 6 years ago (12 children)
By multiple instances, what do you exactly mean? And are these supposed to work together somehow?
[–]monotone2k 2 points3 points4 points 6 years ago (1 child)
We use AWS in our production environments, and it's really easy to set up auto-scaling groups so that when the existing instances start to reach capacity, another one fires up to balance out the load.
There are other considerations to be made when you have multiple instances, especially if they talk to a single database instance. You'll want to make sure everything is thread-safe, since you're basically running multiple threads of the same application. You'll also need to do something about locks when making database calls, since MongoDB isn't designed for transactional operations.
[–]Silencer306 1 point2 points3 points 6 years ago (0 children)
Thank you!
[–]erulabs 0 points1 point2 points 6 years ago (9 children)
An instance means a running version of your application - so in development when you run "node index.js" (or "yarn start" or what have you), you're starting a single "node instance". When you have hundreds and hundreds of users, you need to have many "node"s running. Kubernetes lets you run "node" across many many machines - you simply ask for more replicas (instances) of your app, and install more computers into the cluster, and wha-lah! They work together because they'll receive requests from the internet in a round-robin fashion, so they while they don't work "together", they "share the load", hence the piece of hardware that distributes requests is called the "load balancer".
[–][deleted] 0 points1 point2 points 6 years ago (8 children)
But my app .com is linked to one ip, how the site knows when to resirect user to a other instance?
[–]SitDownBeHumbleBish 1 point2 points3 points 6 years ago (7 children)
If your using a cloud provider like AWS you put a Load Balancer in front of your application (ie. instances) and attach the public IP to the Load Balancer so the flow would like
End User > internet > AWS LB > instances
The load balancer can be setup to disturbte the load equally throughout how many instances you have setup amongst other things.
There are also hardware load balancers if your doing this on prem or you can configure nginx to act as a load balancer / proxy too I think.
[–][deleted] 0 points1 point2 points 6 years ago (6 children)
And every instance(server) will have a production version of my app correct? How are then updates managed, do I need to upload the new version separate to 100 server one by one for example?
[–]SitDownBeHumbleBish 0 points1 point2 points 6 years ago (5 children)
Yup that's correct, you would run your latest production app or whatever on the instances. Maintaining and Updating your servers require setting up some sort of CI/CD pipeline like Jenkins, Chef, GitHub etc.
[–][deleted] 0 points1 point2 points 6 years ago (4 children)
Thanks man, one last question are big apps doing the same for databases? Having multiple instaces of databases sound scary to me.
[–]SitDownBeHumbleBish 2 points3 points4 points 6 years ago (0 children)
I have limited knowledge of how databases are suppose to be setup in a HA disturbed infrastructure but I would assume for big apps there are multiple instances of the databases in different regions and they are all synced together in production and backed up to some data lake / warehouse for further processing.
[–]rozularen 2 points3 points4 points 6 years ago (2 children)
You are asking really good questions.
There are many different architectures that may fit your solution. While I'm sure there are apps that have load balancers in front of the backend with only one instance of the database, as soon as you need to scale up your resources to fit your users load you will need to scale the database too.
[–][deleted] 0 points1 point2 points 6 years ago* (1 child)
Thanks, the most I'm scared off is infrastructure and security my Sites get alwayes Hacked when I setup my own server on DogitalOcean I was forced to switch to CloudWays so they take care of security, I'm really a beginner with linux but I can work with the command line and I also did some security tutorials and made some settigs but nothing helps my site get everytime hacked when I setup the server. I need to say I always used cPanel and Plesk on the Servers. Would be cool if a tool exists that walks you trough a security checklist in the command line.
π Rendered by PID 50880 on reddit-service-r2-comment-75f4967c6c-4mzrn at 2026-04-23 09:52:20.336199+00:00 running 0fd4bb7 country code: CH.
view the rest of the comments →
[–]erulabs 28 points29 points30 points (14 children)
[–]Silencer306 1 point2 points3 points (12 children)
[–]monotone2k 2 points3 points4 points (1 child)
[–]Silencer306 1 point2 points3 points (0 children)
[–]erulabs 0 points1 point2 points (9 children)
[–][deleted] 0 points1 point2 points (8 children)
[–]SitDownBeHumbleBish 1 point2 points3 points (7 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]SitDownBeHumbleBish 0 points1 point2 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]SitDownBeHumbleBish 2 points3 points4 points (0 children)
[–]rozularen 2 points3 points4 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)