2

What is the foremost advantage (if there is any at all) of isolating/encapsulating a Microservice in a container while it can be deployed through a process manager such as PM2? To make the question clearer and more meaningful, assuming a service oriented environment with various Microservice (all written in Node for example) where horizontal scalability is very important and where each Microservice would require replication to distribute processing and add processing power.

In this environment there are two options two stack up those Microservices:

1- Each Microservice can be dockerized (via docker, LXC, LXD, etc)

2- Each Microservice can be daemonized (via PM2, Forever, etc)

If we go for the first option, dockerization needs more disk space, more complex routing, and longer time to set up. This is while the second option allows for consuming globally installed dependencies which makes updating such dependencies easier, it would consume less disk space (as much as the physical size of the Microservice only), simpler routing/clustering.

If I wanted to decide I would go for the second option and instead of containers I would add VMs/Physical Machines (Database Server, Cache Server, HTTP Server) where needed. But is there anything that I am actually missing? Are these two really comparable at all? And finally what do containers offer that make them favorable over processes?

Arnold Zahrneinder
  • 4,788
  • 10
  • 40
  • 76
  • I think it is a matter of reliability: if the server with pm2 and all your microservices instances crash, your application will be offline. In a container environment, you have an orchestrator that manage updates, crashes (by region) and so on. – Manuel Spigolon Jul 21 '20 at 08:58
  • @ManuelSpigolon: True, but that would also happen to a container when the host OS crashes. – Arnold Zahrneinder Jul 21 '20 at 09:07
  • I believe that container based hosting is significantly cheaper than having VMs. Containers are known as "high-density" hosting, which is more economical with compute and memory resource than managed processes on a machine. This is especially true when hosting in AWS or Azure. The cost savings can be significant. – tom redfern Jul 21 '20 at 09:29
  • @tomredfern: But VMs and Physical Machines have dedicated resources which allows for optimizing resources required for each particular sub-system. However, the question is Process Management vs. Containers in a single machine. – Arnold Zahrneinder Jul 21 '20 at 09:32
  • On a single machine I don't think there's benefit. – tom redfern Jul 21 '20 at 10:06
  • @ArnoldZahrneinder Containers have restart policies, thus you can set it to automatically restart a container when it crashes or when the host OS restarts/boots. So if the OS crashes and you have it restarting your containers will be up and running without your intervention. – Exadra37 Jul 21 '20 at 11:12
  • @Exadra37 So do process managers! and that it can actually be configured more flexibly in process managers (for example PM2). That is why I asked the question, because both of these deployment methods pretty much offer the same thing with process managers being more light weight and more maintainable. – Arnold Zahrneinder Jul 21 '20 at 12:00
  • I think if an OS in a container is to crash then the host OS can crash too. In that case all daemonized process start up again when the OS boots. And I don't see what benefit can a containerized environment provide in this case. – Arnold Zahrneinder Jul 21 '20 at 12:03
  • If a container OS crashes it does not affect at all the OS in the host running Docker. I am not an expert in PM2, but once they are tied up to the host I immediately discard them, because with containers I have isolation, aka I can play as many times as I want with the setup without messing the host OS, while with PM2 that is not true. Containers when well configured also offer some security isolation. – Exadra37 Jul 21 '20 at 12:12
  • @Exadra37 `Containers when well configured also offer some security isolation` This is a good point. – Arnold Zahrneinder Jul 21 '20 at 12:13

0 Answers0