Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Bug Stories: How Do I Call Myself?

DZone's Guide to

Bug Stories: How Do I Call Myself?

In another one of his Bug Stories, Oren Eini shares a tale of connectivity in any non-trivial, clustered database setup. Sound interesting? Read on for more!

Free Resource

Container Monitoring and Management eBook: Read about the new realities of containerization.

This bug is actually one of the primary reasons we had a Beta 2 release for RavenDB 4.0 so quickly.

The problem is easy to state: we had a problem in any non-trivial deployment setup where clients would be utterly unable to connect to us. Let us examine what I mean by non-trivial setup, shall we?

A trivial setup is when you are running locally, binding to “http://localhost:8080.” In this case, everything is simple, and you can bind to the appropriate interface and when a client connects to you, you let it know that your URL is “http://localhost:8080.”

Hm… this doesn’t make sense. If a client just connected to us, why do we need to let it know the URL that it needs to connect to us?

Well, if there is just a single node, we don’t. But RavenDB 4.0 allows you to connect to any node in the cluster and ask it where a particular database is located. So the first thing that happens when you connect to a RavenDB server is that you find out where you really need to go. In the case of a single node, the answer is “you are going to talk to me,” but in the case of a cluster, it might be some other node entirely. And this is where things begin to be a bit problematic. The problem is that we need to know what to call ourselves when a client connects to us.

That isn’t as easy as it might sound. Consider the case where the user configures the server URL to be “http://0.0.0.0:8080.” We can’t give that to the client, so we default to sending back the host name in that case. And this is where things started to get tricky. In many cases, the host name is not something that makes sense.

Oh, for internal deployments, you can usually rely on it, but if you are deploying to AWS, for example, the machine host name is of very little use in routing to that particular machine. Or, for that matter, a Docker container host name isn’t particularly useful when you consider it from the outside.

The problem is that with RavenDB, we had a single configuration value that was used both for the binding to the network and for letting the user know how to connect to us. That didn’t work when you had routers in the middle. For example, if my public Docker IP is 10.0.75.2, that doesn’t mean that this is the IP that I can bind to inside the container. And the same is true whenever you have any complex network topology (putting Nginx in front of the server, for example).

The resolution for that was pretty simple: we added a new configuration value that will separate the host that we bind to from the host that we report to the outside world. In this manner, you can bind to one IP but let the world know that you should be reached via another. 

Take the Chaos Out of Container Monitoring. View the webcast on-demand!

Topics:
configuration ,database ,ravendb ,performance ,debugging

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}