influxdata/influxdb-relay

Document common load balancer configuration

gunnaraasen opened this issue ยท 14 comments

We should include basic config files and setup instructions for common load balancer setups starting with HAProxy, Nginx, and maybe ELB.

@gunnaraasen , i just go thought the solution you provided like HAProxy,Nginx,ELB, seems all of them doesnot support UDP forward.
for influxdb-relay, there is UDP protocal support right?
Do you have any idea on this point?

@zhiwzhao The purpose of the load balancer is to separate /query vs /write HTTP requests. Since you cannot perform queries over UDP there is no need to load balance the UDP traffic. Configure the sources of the UDP traffic to send their data directly to the relay.

@zhiwzhao As of March 2016, Nginx announced support for UDP load balancing.

@nathanielc ,the solution you provided can work, but seems not perfect. we need to config source influxdb host and port in load balance and we also need config the relay host in load balance.

but seems there is no good way to do it without your solution.

i write a load balancer with nodejs and support all of /query, /write, http, udp. functions can work but lots of enhancement need to do. maybe need to adopt your solution.

@AdithyaBenny , the feature of nginx is not free, i thing. please check.

@zhiwzhao It's available in the free version as well, I'm using it.

The module required for TCP/UDP load balancing is not compiled in the default version of Nginx. You'll need to either compile from source using --with-stream or use the mainline version.

great,do you have guidance to use it? i would have a try the solution

@zhiwzhao - Here you go

@AdithyaBenny thank you very much! i am already adopt nginx. now my consider is how to improve the performance of nginx ,as my test, the average time cost to write to nginx is more than direct to write to influxdb.

@AdithyaBenny i found there is error in your config,
stream {
upstream test {
server server1:8003;
server server2:8003;
}

server {
listen 7003 udp;
proxy_pass test;
proxy_timeout 1s;
* proxy_responses 1;*
}
}
if not comment on "proxy_responses 1;" , i found the record will be inserted twice. and then i remove the line, everything works fine. please check!

If you're using Relay and UDP, you can simply send UDP traffic to Relay directly, and then point Chronograf/Grafana directly at InfluxDB's HTTP(S) API for queries. There's no need for a load balancer at all, really.

ELB doesn't do path / route based load balancing, however the newfangled AWS Application Load balancer could come to the rescue. I have not tested this yet, will update if I find this approach useful.

I am trying to setup influxdb-relay in Google's GCP, but since influxdb-relay changed from a 200 to a 204 status code for healthcheck, it makes them incompatible. Googles load balancers require a 200 return and are not configurable for other status codes. influxdb-relay is not configurable to return a normal 200 status code.

@gamerscomplete, it's not configurable but certainly tweakable. Try with a status code of 200 in https://github.com/influxdata/influxdb-relay/blob/master/relay/http.go#L118. Change it to http.StatusOK.

@gamerscomplete i was going through the source myself... heres the unified diff (against adaa2ea):

diff --git a/relay/http.go b/relay/http.go
index 73d4f23..5d42c05 100644
--- a/relay/http.go
+++ b/relay/http.go
@@ -114,9 +114,9 @@ func (h *HTTP) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	start := time.Now()

 	if r.URL.Path == "/ping" && (r.Method == "GET" || r.Method == "HEAD") {
-			w.Header().Add("X-InfluxDB-Version", "relay")
-			w.WriteHeader(http.StatusNoContent)
-			return
+		w.Header().Add("X-InfluxDB-Version", "relay")
+		w.WriteHeader(http.StatusOK)
+		return
 	}

 	if r.URL.Path != "/write" {

on a note, has the author gone awol? :D the code really needs some fixing

@ishworgurung Just curious, what do you see as requiring fixing? Found any operational issues?