Your first simple location-based balancer
The case: we have our page copy hosted at Akamai CDN as akapage.myawesomepage.net and at Cloudflare CDS as cfpage.myawesomepage.net. What we want to do is to provide Akamai page as answer for all visitors from European continent and Cloudflare page for the rest of the world.
Step one. Go to FlexBalancers page and create new FlexBalancer:
Let's call it 'mysmart', we select Smart UI type and go to the next step:
Let's suppose we have fallback resource 'backup.myawesomepage.net' (page copy or 'Unavailable' page), so we fill it as 'Fallback' and keep the default 10 seconds TTL.
Press 'Create New FlexBalancer' button :
Now we can see our FlexBalancer mysmart.89f659.flexbalancer.net created.
Step two. Our new balancer has no answers yet, so let's add them (Press 'Add answer' button):
First, let's set our Cloudflare page as an answer for the whole world. We fill in our cfpage.myawesomepage.net , select (keep) 'Global' location and select Cloudflare CDN from Cloud platform selector, then press 'Create answer' button:
Our first answer has been added!
But we need another answer for Europe, so press 'Add new'.
We fill in our akapage.myawesomepage.net , select continent 'Europe' and Akamai CDN from Cloud platform selector, then press 'Create answer' button:
Now we have FlexBalancer with two answers.
What is important:
Our 'Europe' continent is smaller than 'Global (World), so, when the request is processed, FlexBalancer will check if any continent-based answer matches the request location, if not- it will go Global answer.
Step three. Let’s press ‘Test and publish’ button,
confirm the Deployment,
and get the final window:
It tells us not to forget to point our page domain name to mysmart.89f659.flexbalancer.net using CNAME record, so requests will go to FlexBalancer and it will manage all answers (Europe to Akamai, other world - to Cloudflare page copies).
Now, let’s test how it works using the dig tool:
We will emulate the DNS-request via dig-utility, using subnets and IPs from different countries:
From France (Europe) we get akapage.myawesomepage.net:
And from the USA we get cfpage.myawesomepage.net:
Let's test it from another computer.
From Denmark (Europe) we get akapage.myawesomepage.net:
And from Canada we get cfpage.myawesomepage.net:
Everything works as expected!