<h2>Multiple apps on the same server</h2>
<blockquote>
<p>But what if I have a Node.js server application? I could run multiple of those on the same machine without any kind of virtualization.</p>
</blockquote>
<p>Yes, you can run multiple apps or multiple instances of the same app on a server. The problem is that these apps will <em>interfere</em>.</p>
<p>Some examples of resources, that might interfere:</p>
<ul>
<li>They would all like to listen to the same <strong>port</strong> e.g. 8080.</li>
<li>If they need more <strong>memory</strong>, they will eventually fight about the same memory.</li>
<li>If the apps is busy, they will fight about the same CPU resource.</li>
<li>They all would like to write logs to the same files on the file system.</li>
<li>They all might want to save data to the same place on the file system.</li>
</ul>
<p>This needs to be managed in some way, and we don't want to do it manually.</p>
<p>With Virtual Machines on the same server, or Containers on the same server, each instance get its own IP-address, each instance can listen to what port it wants, e.g. all can listen to 8080. You can bound how much memory an instance has, e.g. 1GB - so if an app leaks memory, it does not affect the others. You can also bound how much CPU each instance can use, so they only use their fair share. Each instance has its own view of the filesystem, so all instances can write to the same path (as they see it) - even though it is technically different places.</p>
<h2>Multiple instances - Availability</h2>
<blockquote>
<p>Why is even running multiple instances necessary?</p>
</blockquote>
<p>What would you do when you need to patch the server and need to restart it? How will you upgrade your app to a new version? What happens if the hardware on your server crash? What happens when your single instance can not handle all the traffic?</p>
<p>The answer to all those questions, typically is: run more than one instance of your app, and let a load balancer forward the traffic to your instances that are alive.</p>
<h2>Why virtualization?</h2>
<blockquote>
<p>Why were virtual machines needed?</p>
</blockquote>
<p>They are not really needed. This is more about economics, a way to use your expensive hardware more efficiently.</p>
<p>If you start a new project, but a server - the server is very powerful and expensive. If you only start a Node.js app on this server, it will probably take long time before this Node.js app is so popular that it need to use the full server. It would be better if you could rent only a small part of the server in the beginning - that is how the Cloud with AWS and Google Cloud Platform works.</p>

CC BY-SA 4.0
2020-12-12T23:04:12.223Z
2020-12-12T23:04:12.223Z
Jonas
<p>I'm trying to learn about virtualization and containers. In an educational video it is said that the introduction of virtual machines was a big deal because it made companies available to run multiple server instances on the same machine, so they did not have to necessarily buy a new machine just to run a new instance.</p>
<p>But what if I have a Node.js server application? I could run multiple of those on the same machine without any kind of virtualization. Why is even running multiple instances necessary? Why were virtual machines needed? My best guess is that Node.js is designed to support running multiple instances (the instances doesn't &quot;know&quot; about each other), therefore they are not needed, but back then the servers that they used would have &quot;known&quot; about each other if they weren't separated by virtual servers.</p>
<p>Do people do the same using containers? If I have a microservices architecture, and let's say that I only have one computer, am I using containers only to check whether they run correctly in different environments, or do I create multiple of even the same microservice?</p>
<p>Please excuse my sloppy wording, I mainly try to get what is it that I'm actually missing / misunderstanding, and I try to convey my abstract, high-level understanding of the issue.</p>
<p>Link to video: <a href="https://youtu.be/JSLpG_spOBM?t=77" rel="nofollow noreferrer">https://youtu.be/JSLpG_spOBM?t=77</a></p>

<containers><microservices><node.js><virtualization>
Why is it necessary to have virtual machines to run multiple server instances?
szeb
# Why is it necessary to have virtual machines to run multiple server instances?

(Asked by: username_0 on 2020-12-09)

I'm trying to learn about virtualization and containers. In an educational video it is said that the introduction of virtual machines was a big deal because it made companies available to run multiple server instances on the same machine, so they did not have to necessarily buy a new machine just to run a new instance.

But what if I have a Node.js server application? I could run multiple of those on the same machine without any kind of virtualization. Why is even running multiple instances necessary? Why were virtual machines needed? My best guess is that Node.js is designed to support running multiple instances (the instances doesn't "know" about each other), therefore they are not needed, but back then the servers that they used would have "known" about each other if they weren't separated by virtual servers.

Do people do the same using containers? If I have a microservices architecture, and let's say that I only have one computer, am I using containers only to check whether they run correctly in different environments, or do I create multiple of even the same microservice?

Please excuse my sloppy wording, I mainly try to get what is it that I'm actually missing / misunderstanding, and I try to convey my abstract, high-level understanding of the issue.

Link to video: <https://youtu.be/JSLpG_spOBM?t=77>

**Tags:** containers, microservices, node.js, virtualization


---

## 1 answers

### Answer by username_1 on 2020-12-12. Score: 3 | Accepted answer

## Multiple apps on the same server

> But what if I have a Node.js server application? I could run multiple of those on the same machine without any kind of virtualization.

Yes, you can run multiple apps or multiple instances of the same app on a server. The problem is that these apps will *interfere*.

Some examples of resources, that might interfere:

* They would all like to listen to the same **port** e.g. 8080.
* If they need more **memory**, they will eventually fight about the same memory.
* If the apps is busy, they will fight about the same CPU resource.
* They all would like to write logs to the same files on the file system.
* They all might want to save data to the same place on the file system.

This needs to be managed in some way, and we don't want to do it manually.

With Virtual Machines on the same server, or Containers on the same server, each instance get its own IP-address, each instance can listen to what port it wants, e.g. all can listen to 8080. You can bound how much memory an instance has, e.g. 1GB - so if an app leaks memory, it does not affect the others. You can also bound how much CPU each instance can use, so they only use their fair share. Each instance has its own view of the filesystem, so all instances can write to the same path (as they see it) - even though it is technically different places.

## Multiple instances - Availability

> Why is even running multiple instances necessary?

What would you do when you need to patch the server and need to restart it? How will you upgrade your app to a new version? What happens if the hardware on your server crash? What happens when your single instance can not handle all the traffic?

The answer to all those questions, typically is: run more than one instance of your app, and let a load balancer forward the traffic to your instances that are alive.

## Why virtualization?

> Why were virtual machines needed?

They are not really needed. This is more about economics, a way to use your expensive hardware more efficiently.

If you start a new project, but a server - the server is very powerful and expensive. If you only start a Node.js app on this server, it will probably take long time before this Node.js app is so popular that it need to use the full server. It would be better if you could rent only a small part of the server in the beginning - that is how the Cloud with AWS and Google Cloud Platform works.


---

