Question to HAProxy experts

We have two systems, let’s say legacy and new one. We also have hundred millions of clients, and part of them already support migration to the new system.
In order to distribute migrated / non-migrated traffic among two systems, we want to setup haproxy layer on top of it.
For each api call, we want to check if client is migrated or not, according to the list of clients, so migrated clients should be routed to the new system, and non-migrated clients should be routed to legacy.
And we are expecting around 50000 qps.
Question: what is the best solution to implement such routing? I believe having some file on haproxy hosts to let lua script check if client is present in this file can drop down the performance a lot.
Or having some database like Redis will also add more latency and network noise.
Want to hear your ideas, thank you in advance.

I would say the most efficient way to split the traffic is based on different endpoints (i.e. hostname) or different paths, both which are efficiently handled by HAProxy.

Alternatively, if applicable, encode in a cookie if the user is migrated or not, and configure HAProxy to route based on that.

Failing that, assuming you have a “token” (part of the URL, headers, or request), is to use ACL maps or the map fetch sample (see https://cbonte.github.io/haproxy-dconv/2.5/configuration.html#7.3.1-map); you could seed this file initially with the current split, and then by using http-request set-map to dynamically update this (see https://cbonte.github.io/haproxy-dconv/2.5/configuration.html#4.2-http-request%20set-map).

(If your split is static, then you can just use a basic ACL with -f to load the migrated tokens.)