neighbourhoodie-nnh-logo

CouchDB and Docker posted Tuesday, November 3, 2020 by The Neighbourhoodie CouchDB Team

Docker is an extremely popular way of deploying any kind of application in many different environments. Deploying CouchDB is no exception, the CouchDB project even maintains its own set of Dockerfiles, as well as a helm chart to help orchestrate multiple containers as a cluster on Kubernetes.

All of these are rather advanced concepts that we are not going into in this article. But if you need any particular help with this, we’re always happy to help.

First off, Docker is a fine choice in many cases:

  • quickly try out something without having to worry about dependencies and proper setup
  • recreate a production environment on a developer workstation
  • make it easy to deploy a well-defined production environment repeatedly

We have many CouchDB customers and users that use CouchDB successfully inside Docker.

However.

The way Docker works can introduce problems when running CouchDB in high-performance situations.

One of Docker’s core features is isolation of containers. In order to achieve this, Docker introduces a virtual networking and a virtual file system layer. Both of these layers can introduce delays and consistency issues to the point where running CouchDB inside Docker is slower than outside of Docker.

As a database, CouchDB naturally has the highest demands on data access. Any additional delays in getting bytes to and from disk are going to make all CouchDB operations slower.

As a networked database, the same is true for Docker’s networking layer. Especially when running a CouchDB cluster in Docker containers, the networking layer leads to significant performance degradation.

We are constantly evaluating new versions of Docker and we’ll be happy to report when running CouchDB inside it is flawless. But until then, we’ll maintain this warning.

And sometimes, there is just the odd unexplainable issue.

In conclusion: there are many valid use-cases for running CouchDB inside Docker, and you might even make a conscious trade-off where the ease-of-use of Docker trumps the required performance for your database, or your load is just not that bit relative to the computing resources you have available.

But if you need to have CouchDB be its fastest and most reliable self, you should run it outside of Docker.