envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.99k stars 4.81k forks source link

Add support of MYSQL health check #13551

Open austin-zhu opened 4 years ago

austin-zhu commented 4 years ago

Title: Add MYSQL health check

Description: Currently, Envoy seems only support HTTP, TCP and REDIS (as an extension) type of health check when positively checking upstream endpoint's healthiness. In HAProxy, it has built-in mysql-check to perform a simple auth test or mysql handshake packet as the health check approach.

The advantages of having MYSQL health check is to better exclude replicas during DB failover and/or overloaded scenario. TCP health check will be passed as long as the port is opened by mysql, but it won't sufficient to rule out those unready or unhealthy replicas. Outlier ejection seems only work for HTTP traffic and cannot help so much under this case.

Actually, there are some work/proposals of supporting mysql relevant area in the community already, see below. I wonder whether it makes sense for community to consider adding MYSQL health check support as another extension. Hopefully, it is not very controversial.

Happy to discuss more.

[optional Relevant Links:] https://github.com/envoyproxy/envoy/issues/3501 https://github.com/envoyproxy/envoy/pull/3502 https://github.com/envoyproxy/envoy/pull/4975

snowp commented 4 years ago

I think adding a MySQL health check makes perfect sense as long as it gets added as an extension and not into core. Since we don't currently have an extension point for health checks as far as I know, the first step would probably be to add that extension point.

dio commented 4 years ago

Can we use a similar pattern as source/extensions/health_checkers/redis, configured using the CustomHealthCheck?

snowp commented 4 years ago

Seems like we already have this extension point then :) Yeah that should make this easier

dio commented 4 years ago

@Jason-Jian @juchem do you mind if someone picks up your PR here: https://github.com/envoyproxy/envoy/pull/3502/files as an answer to this ticket?

dio commented 4 years ago

NVM, @Jason-Jian @juchem seems like @austin-zhu is part of your team. 😅

austin-zhu commented 4 years ago

Sorry for the late response. Yes, Marcelo and Jason are both my teammates (at least, were). We tried to implement this years ago but did not get a chance to merge it to master. I believe the code structure has been changed a lot over years so it might be easier to redo the work based on Marcelo's earlier logic and make it as another extension endpoint. This issue is just to understand how community thinks about adding this feature. It looks positive, I will say?

dio commented 4 years ago

@austin-zhu I think so yeah. Do you have plan to work on this?