1

What we have:

  • 3 stateful backend servers located in different regions.
  • Mqtt broker in each region (with IoT-devices connected).
  • Users that related to specific region, to able to see they IoT data.
  • Unique host name for each server.

What we want:

  • One host name to serve all users
  • Mqtt can still connected to each backend by i'ts unique host name
  • The decision where to redirect should come from the user information and not from the IP (for example field in JWT)

Did the GCP HTTP(S) load balancing is capable to do such think, or there is a technical limitation?

Any ideas will be much appreciated!

Leon.fon
  • 36
  • 5

2 Answers2

2

I think that you can achieve the most with HTTPS Global load balancer (GLB). You have here an article that can help you in the setup.

Only the redirect condition seems tricky. Initially the GLB route to the closest region to the user (thus based on IP), and then you can set up a sticky param, either based on IP or on cookies. I'm not sure that feat your latest requirement. You can also route to a backend according with the url path provided. But not from the JWT claims.

guillaume blaquiere
  • 66,369
  • 2
  • 47
  • 76
  • Thank you for the response. My main problem is the redirection based on user information. I found that for in nginx for example i can write custom lua scripts for redirection and etc. I thought that GLB will provide me that flexibility. Now i think to combine GLB with nginx backends located in each zone. – Leon.fon Dec 02 '19 at 10:38
  • 1
    You can't customize the GLB as you can do it on NGINX. You can deploy a NGINX in each zone, with one main issue: the high availability of this NGINX servers. Take care of it and enjoy! – guillaume blaquiere Dec 02 '19 at 12:37
1

If you want one hostname to serve all users, you can use HTTP(S) load balancer for achieving this. Here is an article which gives more insight about the same 1.

Your need to redirect based on user information and not from the IP, can be achieved via Session affinity :2

Google Cloud HTTP(S) Load Balancing offers two types of session affinity:

  • Client IP affinity 3 sends requests from the same client IP address to the same backend.

  • Generated cookie affinity 4 sets a client cookie when the first request is made, then sends requests with that cookie to the same backend.

When you use session affinity, the RATE balancing mode is recommended, rather than UTILIZATION.

  • I don't think that session affinity allows me to use custom logic (i need to redirect specific user to specific backend the connection i can get from DB first time on login). – Leon.fon Dec 02 '19 at 10:43
  • Unfortunately, customizing the GLB based on specific user information is not possible in GCP. Alternatively, you can use URL mapping: [1] [1]: https://cloud.google.com/load-balancing/docs/url-map – Anurag Sharma Dec 02 '19 at 20:42