What is the advantage of a docker container for a memcached instance?

One example of Docker is for a container with Memcached settings. I am wondering why this is needed from a VM configured with Memcached? I assume that it would be pointless to have more than one memcached docker container running under the same host, and the only real advantage is the advantage of the β€œspin” speed of the memcached stack in the docker container and Memcached through the virtual machine. Is that right?

Also, how to set the memory that memcached will use in the docker container? How will this work if there are two or more Memcached docker containers under the same host? (I again assume that two or more does not make sense).

+6
source share
3 answers

I am wondering why this is needed from a VM configured with Memcached?

Security:. If someone violates memcached and file system trojans, it does not matter - the file system is discarded when a new memchached starts.

Insulation:. You can tightly restrict each container so that it does not use too much RAM.

Standardization: Currently, each application / database / cache / load balancer should record what to install, what to configure, and what to run. There is no standard (and no shortage of tools such as puppet, chef, etc.). But these tools are very complex, not OS independent (despite their requirements) and carry the same complexity from development to deployment.

With docker, all this is just a container starting with run BLAH . If your application has 5 levels, you have only 5 containers to run, with a little orchestration on top. Developers never need to "look into the container" if they do not develop at this level.

Resources: You can deploy 1000 docker containers on a regular PC, but you will have problems starting 100 virtual machines. The limit is both the processor and the RAM. Dock containers are simply processes in an "enhanced" chroot. There are many background processes on the virtual machine (cron, logrotation, syslog, etc.), but there are additional no for dockers.

I guess it would be pointless to have more than one memcached docker container running under the same host

It depends. There are times when you want to split your RAM into packages rather than global. (for example, imagine if you want to spend 20% of the cache for caching users and 40% of the cache for caching files, etc.).

In addition, most fragments schemes are difficult to expand, so people often start with many β€œvirtual” fragments, and then expand to physical boxes when necessary. Thus, you can start with your application, knowing about 20 memcached instances (selected based on the identifier of the object). First, all 20 work on the same physical server. But later you divided them into 2 servers (10/10), then into 5 servers (4/4/4/4) and, finally, into 20 physical servers (1 memory each). This way you can scale the 20x application by simply moving the virtual machines and not changing your application.

the only real advantage is the advantage of the speed of the "rotation" of the memcached stack in the docker container and Memcached through the virtual machine. Is it correct?

No, this is just a small advantage. see above.

Also, how to set the memory that memcached will use in the docker container?

In the docker run just use -m .

How will this work if there are two or more Memcached docker containers under the same host? (I again assume that two or more does not make sense).

Same. If you did not set a memory limit, that would be exactly like starting 2 memcached processes on the host. (If someone fills the memory, both will go out of memory.)

+18
source

There seem to be two questions here ...

1 - Manual, as you described. You can isolate the memcached instance (and configuration) in a separate container so that you can run several on a specific host. In addition, moving the memcached instance to another host is pretty trivial and just requires updating the application configuration in the worst case.

2 - docker run -m <inbytes> <memcached-image> limit the amount of memory that the memcached container can use. You can run as many of them as you want under one host.

+2
source

Something may be missing for me, but Memcaching just says something about memory usage, right? Docker containers are very efficient when using disk space. You do not need an OS on each virtual machine, but you can share resources. A transparent extension with pictures on docker.io.

0
source

Source: https://habr.com/ru/post/950582/


All Articles