micro/server
Shulhan 1599d717af Add option to enable TCP check with Consul registry
One disadvantage of using TTL based health check is the high network
traffic between Consul agent (either between servers, or between server
and client).

In order for the services considered alive by Consul, microservices must
send an update TTL to Consul every n seconds (currently 30 seconds).

Here is the explanation about TTL check from Consul documentation [1]

    Time to Live (TTL) - These checks retain their last known state for a
    given TTL. The state of the check must be updated periodically over
    the HTTP interface. If an external system fails to update the status
    within a given TTL, the check is set to the failed state. This
    mechanism, conceptually similar to a dead man's switch, relies on the
    application to directly report its health. For example, a healthy app
    can periodically PUT a status update to the HTTP endpoint; if the app
    fails, the TTL will expire and the health check enters a critical
    state. The endpoints used to update health information for a given
    check are the pass endpoint and the fail endpoint. TTL checks also
    persist their last known status to disk. This allows the Consul agent
    to restore the last known status of the check across restarts.
    Persisted check status is valid through the end of the TTL from the
    time of the last check.


Hint:

    TTL checks also persist their last known status to disk. This allows
    the Consul agent to restore the last known status of the check
    across restarts.

When microservices update the TTL, Consul will write to disk. Writing to
disk means all other slaves need to replicate it, which means master need
to inform other standby Consul to pull the new catalog. Hence, the
increased traffic.

More information about this issue can be viewed at Consul mailing list [2].

[1] https://www.consul.io/docs/agent/checks.html
[2] https://groups.google.com/forum/#!topic/consul-tool/84h7qmCCpjg
2018-03-14 19:40:59 +07:00
..
debug switch to stdlib context 2018-03-03 11:53:52 +00:00
mock Add mock server 2016-04-16 00:02:55 +01:00
rpc Add packages for the defaults 2016-03-14 10:45:38 +00:00
buffer.go Updated codec interface and code. Painful stuff 2015-11-28 11:22:29 +00:00
context.go switch to stdlib context 2018-03-03 11:53:52 +00:00
debug.go Add debug stats handler 2016-05-28 22:30:47 +01:00
extractor_test.go switch to stdlib context 2018-03-03 11:53:52 +00:00
extractor.go move addr extractor to misc 2017-01-12 13:20:34 +00:00
handler.go move the option 2016-05-26 20:43:05 +01:00
options.go Add option to enable TCP check with Consul registry 2018-03-14 19:40:59 +07:00
rpc_codec_test.go server/rpc_codec: if c.codec.Write fails, reset write buffer and encode an error message about the encoding failure 2017-07-17 14:21:43 -04:00
rpc_codec.go server/rpc_codec: if c.codec.Write fails, reset write buffer and encode an error message about the encoding failure 2017-07-17 14:21:43 -04:00
rpc_handler.go Support endpoint metadata 2016-05-26 18:01:02 +01:00
rpc_request.go Rename to hdlrWrappers for symmetry sake 2015-12-02 21:12:09 +00:00
rpc_server.go Add option to enable TCP check with Consul registry 2018-03-14 19:40:59 +07:00
rpc_service.go switch to stdlib context 2018-03-03 11:53:52 +00:00
rpc_stream.go switch to stdlib context 2018-03-03 11:53:52 +00:00
server_wrapper.go switch to stdlib context 2018-03-03 11:53:52 +00:00
server.go switch to stdlib context 2018-03-03 11:53:52 +00:00
subscriber.go switch to stdlib context 2018-03-03 11:53:52 +00:00