apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.3k stars 2.49k forks source link

help request: Does it support stream poxy match with difference host with same apisix port to difference upstream? #11516

Open Mararesliu opened 3 weeks ago

Mararesliu commented 3 weeks ago

Description

I use APISIX for mysql proxy, Can I use different domain to the same port with apisix for different mysql instance? Can connect with different host to mysql instance.

By the way. If i change some config, and apisix reload when in high traffic, Will there be any connection issues?If that How can i prevent?

THX

Environment

Revolyssup commented 3 weeks ago

Do you mean something like

Client -> Apisix @ x:y -> mysql1 Client -> Apisix @x:z -> mysql2 ?

Then you can create two stream routes pointing to same upstream

apisix:
  stream_proxy: # TCP/UDP proxy
    tcp: # TCP proxy address list
      - x:y
      - x:z
curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 -H "X-API-KEY: $admin_key" -X PUT -d '
{
    "server_addr": "x",
    "server_port": y,
    "upstream": {
        "nodes": {
            "mysql1 address": 1
        },
        "type": "roundrobin"
    }
}'

curl http://127.0.0.1:9180/apisix/admin/stream_routes/2 -H "X-API-KEY: $admin_key" -X PUT -d '
{
    "server_addr": "x",
    "server_port": z,
    "upstream": {
        "nodes": {
            "mysql2 address": 1
        },
        "type": "roundrobin"
    }
}'
Revolyssup commented 3 weeks ago

@Mararesliu There will be no dropped connections when you do apisix reload.

Mararesliu commented 2 weeks ago

Can I setting different Domain name points to the same apsix ip and port, route to different mysql instance? How APISIX identify domain to match different instance? Is that I can setting "server_addr" mysql100.prd.com with it?