influxdata / influxdb-relay

Service to replicate InfluxDB data for high availability
MIT License
855 stars 350 forks source link

Document common load balancer configuration #14

Open gunnaraasen opened 8 years ago

gunnaraasen commented 8 years ago

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

zhiwzhao commented 8 years ago

@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?

nathanielc commented 8 years ago

@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.

acherunilam commented 8 years ago

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

zhiwzhao commented 8 years ago

@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.

acherunilam commented 8 years ago

@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.

zhiwzhao commented 8 years ago

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

acherunilam commented 8 years ago

@zhiwzhao - Here you go

zhiwzhao commented 8 years ago

@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!

mrcrilly commented 8 years ago

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.

Hashfyre commented 7 years ago

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.

gamerscomplete commented 7 years ago

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.

ishworgurung commented 7 years ago

@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.

ishworgurung commented 7 years ago

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

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

voiprodrigo commented 6 years ago

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