Bgp bestpath as-path multipath-relax, why this BGP feature is used?. Let's understand the case with the topology and I will tell you the real-life use case of the Bgp bestpath as-path multipath-relax feature.
In EBGP Multipath, we have two rules to satisfy the Multipathing requirements. The number of AS has to be the same across the two paths and the AS number needs to be the same as well. In the above topology, for the destination prefix, 192.168.0.0/24, we have two paths. Both of the paths are 2 AS Path Lenght, AS 100, and AS200. And both of the paths consist of the same ASes, AS 100 and AS 200. Thus, on the above topology, if we enable EBGP Multipath feature it just works. We will change the AS number in one of the paths in the below topology and EBGP Multipath will not work.
Let's remember the rules again. 1: Number of AS Paths 2. AS number in the AS Paths has to be the same. In the above figure, the number of AS in both of the paths is 2. But AS numbers are different. One of the paths: AS 100 - AS400, another path: AS100 - AS300 Thus, across two different paths, as we have different AS numbers, although you have 2 AS in both of these paths, you can not do EBGP Multipath, by default.
If you want to enable EBGO Multipath, even if you have different AS numbers, then you need Bgp bestpath as-path multipath-relax configuration command.With this, basically, you are telling the routers, even if you have different AS numbers across the paths, if the AS Path length is the same, then behave a little bit relax and allow me to do the EBGP Multipath, Hope it is more clear now and the functionality of this feature.
Bonus: This feature is used in CLOS topologies in Hyperscale Datacenters today and you can find more information about it on RFC 7938 immediately.