-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service discovery #557
Service discovery #557
Conversation
@jskswamy I'm not sure I understand the rationale behind this but the proxy cannot be removed, it's the critical point that avoids clients talking with the wrong primary in case of partitioning. It's explained in the architecture doc and the FAQ. |
@sgotti this isn’t my PR!! |
@wchrisjohnson sorry, I meant @jskswamy |
Introduce a separate command to register stolon slave and master information for service discovery. This will potentially solve resolve Allow clients to connect to standby replicas in RO mode and improve performance by connecting to the master directly without the need for We ran benchmark tests by connecting directly to the master without proxy and we saw significant improvement in Postgres performance Test result of running benchmark tests by connecting to proxy
Test result of running benchmark tests by connecting to directly to master
This commit has proof of concept for registering the Usage:
stolon-register [flags]
Flags:
--cluster-name string cluster name
--debug enable debug logging
-h, --help help for stolon-register
--kube-resource-kind string the k8s resource kind to be used to store stolon clusterdata and do sentinel leader election (only "configmap" is currently supported)
--log-color enable color in log output (default if attached to a terminal)
--log-level string debug, info (default), warn or error (default "info")
--metrics-listen-address string metrics listen address i.e "0.0.0.0:8080" (disabled by default)
--register-backend string register backend type (consul) (default "consul")
--register-endpoints string a common-delimited list of store endpoints (use https scheme for tls communication) defaults: http://127.0.0.1:8500 for consul (default "http://127.0.0.1:8500")
--store-backend string store backend type (etcdv2/etcd, etcdv3, consul or kubernetes)
--store-ca-file string verify certificates of HTTPS-enabled store servers using this CA bundle
--store-cert-file string certificate file for client identification to the store
--store-endpoints string a comma-delimited list of store endpoints (use https scheme for tls communication) (defaults: http://127.0.0.1:2379 for etcd, http://127.0.0.1:8500 for consul)
--store-key string private key file for client identification to the store
--store-prefix string the store base prefix (default "stolon/cluster")
--store-skip-tls-verify skip store certificate verification (insecure!!!)
--version version for stolon-register Example usage for the following cluster configuration === Active sentinels ===
ID LEADER
094261bb true
9e95d704 false
f9683b9a false
=== Active proxies ===
No active proxies
=== Keepers ===
UID HEALTHY PG LISTENADDRESS PG HEALTHY PG WANTEDGENERATION PG CURRENTGENERATION
00660a8c true 127.0.0.1:5434 true 2 2
3544bfc9 true 127.0.0.1:5437 true 2 2
8faab17a true 127.0.0.1:5436 true 2 2
9a73a450 true 127.0.0.1:5435 true 4 4
=== Cluster Info ===
Master: 9a73a450
===== Keepers/DB tree =====
9a73a450 (master)
├─00660a8c
├─3544bfc9
└─8faab17a stolon-register --cluster-name stolon --store-backend consul 2018-08-28T23:15:03.509+0530 INFO cmd/register.go:126 successfully registered master stolon with uid a0a37028
2018-08-28T23:15:03.510+0530 INFO cmd/register.go:138 successfully registered slave stolon with uid ac670a1d
2018-08-28T23:15:03.511+0530 INFO cmd/register.go:138 successfully registered slave stolon with uid b5b5f468
2018-08-28T23:15:03.511+0530 INFO cmd/register.go:138 successfully registered slave stolon with uid 852945a0 consul exposes the both master and slave via its DNS dig +short @localhost -p 8600 slave.stolon.service.consul
127.0.0.01 dig +short @localhost -p 8600 master.stolon.service.consul
127.0.0.01 |
@sgotti this does not replace |
@jskswamy you said: "improve performance by connecting to the master directly without the need for stolon-proxy." But clients should only use the stolon-proxy and shouldn't be encouraged to bypass it. If you want to improve performance (but my tests on Linux, since we only support Linux, are quite different than yours) then let's do it improving the stolon-proxy (have you tried compiling it with go1.11 that implements splice on Linux?), please open a new issue with your benchmarks and how to reproduxe them so we can track it. |
I'll raise a separate issue with the performance result after compiling it with go1.11, any reason why the client shouldn't connect directly to master? This PR needs following feature before it can be merged to master
|
@sgotti I've created this PR to get your opinion of adding a feature to |
@jskswamy I'll happily review this PR and the idea behind registering to a service discovery system, I just don't agree on the part regarding bypassing the stolon-proxy. Have you read the architecture doc and the FAQ? They should explain quite well the reason, take also a look at the integration tests that tests various partitioning cases. If there's something not clear feel free to ask (also on the gitter channel). |
I agree that this solution will not |
cmd/register/cmd/discovery.go
Outdated
} | ||
} | ||
|
||
// A HTTPClient has necessary method to make http calls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you just use consul client lib (I'm not asking for libkv since I'd like to ditch it)? In this way it'll be easier to handle context, tls etc... It's already vendored (perhaps needs an update to the latest version).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, will make necessary changes to use consul client lib instead of HTTP calls
|
||
// Package mock_store is a generated GoMock package. | ||
package mock_store | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The store mock could be moved to the project internal dir so it could be used also by other packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've introduced gomock and the store.go is generated using gomock
, would like to hear from you on adopting it in the project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jskswamy no problem adopting it. Currently we focused on creating a lot integration tests to test real world scenarios so we didn't had the need to mock the store.
@jskswamy Thanks for the PR! I like the idea of having a separate command. I just did a very fast review of two pieces. Here some more questions:
|
|
bdbb81a
to
66a7ca2
Compare
4bb5da3
to
63ef03b
Compare
9a94327
to
bcd799c
Compare
Made all the requested changes
Following minor tweak needs to be handled, would like to hear from you @sgotti could you kindly review the changes?
|
@sgotti Please go through the changes I've made the following pending changes as well
|
1d3e1dd
to
3bb2ffc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jskswamy Great work! I haven't tested it so just a fast review, see inline comments plus some other comments here:
-
I checked out out your PR and noticed that there were some unneeded files (mitchellh/mapstructure) and some changed consul client files in the vendor directory. Probably you forgot to run
go mod vendor
and commit the new vendor files. -
Are the unit tests enough for you to test it or do you also need some integration tests (with a real consul)?
3bb2ffc
to
af5de0b
Compare
e3205ae
to
d34cc5e
Compare
d34cc5e
to
92ad2fa
Compare
Yes unit tests are enough and it covers all the scenarios, review the code and let me know if there is a need for adding integration tests |
@jskswamy Sorry for being late, I'll review it in the next few days. Thanks! |
@jskswamy I haven't tested it directly but it LGTM. Before merging please:
|
f56eb3d
to
3c4a7f2
Compare
…n for service discovery Co-authored-by: Dinesh B <dineshudt17@gmail.com> Co-authored-by: Abdul Rahman K <kadkab.abdul@gmail.com>
3c4a7f2
to
4730d0a
Compare
|
@jskswamy Thanks for your great work! Merging. |
Hello all. I have followed your conversation regarding this PR. It is 2 years old now... I was wondering if this is already into current Stolon? Thanks, Fernando |
Introduce a separate command to register stolon slave and master information for service discovery, this will potentially solve resolve Allow clients to connect to standby replicas in RO mode and improve performance by connecting to the master directly without the need for
stolon-proxy
This commit has proof of concept for registering the
stolon
master and proxy toconsul
for service discovery,