STEPHANIE WONG: In the last episode,
we explained how the GCP global load
balancer is able to overflow traffic
to back in instance scripts in the next closest
region during traffic spikes.
Not only is this more reliable for Beyond Treats'
growing online business, but it also gives dog parents
a better overall experience with lower overall latency risks.
PRIYANKA VERGADIA: But the Beyond Treats leadership
is hesitant, and they want to save cost
in as many places as possible.
They have a new claim to fame after being featured on TV,
and are new to serving online customers around the world.
Will global load balancing give them a noticeable difference
in performance versus regional?
STEPHANIE WONG: Today, we're going to find that out.
[MUSIC PLAYING]
What we'll be creating today is a simple test web server
running a CPU-intensive application
that computes Mandelbrot sets.
PRIYANKA VERGADIA: What are Mandelbrot sets?
STEPHANIE WONG: A Mandelbrot set is
generated by computational iteration, which
means to repeat a process over and over again.
And that will be a Python script we install on our load test
instances.
PRIYANKA VERGADIA: Huh.
OK.
I'm intrigued.
STEPHANIE WONG: We'll then measure network capacity
using load testing tools on one VM instance.
Next, we'll add a single region load balancer
with back ends in the same region,
and then measure the response time.
PRIYANKA VERGADIA: And then let me guess, after that, we
will test the performance when we scale
the network to multiple regions using global load balancing,
and then compare that with the performance using
a single regional load balancer.
STEPHANIE WONG: Yes.
Ding, ding, ding!
Exactly.
PRIYANKA VERGADIA: Awesome.
I am super excited.
Let's do it.
Let's go through the ingredients.
STEPHANIE WONG: Yes.
Here they are.
You'll need load testing tools like siege and httperf.
Siege simulates requests from a specified number of users,
so you can see the capacity and expected response
times for an application.
httperf sends a specific number of requests per second,
regardless of whether responses or errors are received.
It tells you how applications respond to load.
PRIYANKA VERGADIA: You also need a single [INAUDIBLE] machine
instance back end, a single region load balancer,
and a single region managed instance group.
And finally, a global load balancer with multi-regional
managed instance groups.
STEPHANIE WONG: To start, create a VPC network for testing,
then define a firewall rule to allow internal traffic
and allow SSH traffic to the VPC.
Now, lets determine the serving capacity
of a single VM instance.
Create a VM called web server with four CPUs.
Include a startup script that installs the Mandelbrot server.
Create a firewall rule to allow external access to it,
and then grab the VM public IP address.
Enter it in your browser, and you get the computed Mandelbrot
set.
PRIYANKA VERGADIA: Then create a second VM in the same zone
called load test.
[? Text ?] ssh into the load test instance
and install siege and httperf.
And try to request around 20 requests
from four parallel users.
You should get an output of about 5.05 requests per second.
Using httperf, run 500 requests at the rate of four requests
per second, and repeat it at different rates,
like 5, 7, and 10 requests per second.
You will see that the system can handle
five requests per second, and then drastically
jumps in response time and connection errors
when you have 7 or 10 connections per second.
STEPHANIE WONG: OK, now let's put a single region load
balancer in front with the managed instance
group in the same region.
Once you create the https load balancer
with three VMs in the same region using a managed instance
template, and health checks, you can run the same load test
against the load balance system.
As a load increases past serving capacity,
the average and maximum request latency increases sharply.
With 10 requests per second, the average request latency
is close to 500 milliseconds.
But with 20 requests per second, the latency
is 5,000 requests per second.
It's a tenfold increase.
Your dog fans are not going to be happy
when you have a flash buy one get one free sale on dog
birthday cakes.
PRIYANKA VERGADIA: Now, here's the real test.
Let's set up a global web server with https load balancing
with back ends deployed in multiple regions.
Once you create a managed instance
group, in second region, with a maximum capacity of 10 RPS,
run 500 requests at 10 RPS, and you will get the results.
After the system stabilizes, the average response time
is around 400 milliseconds, at 10 RPS,
and a minor increase to 700 milliseconds, at 20 RPS.
Seems like the discrepancy is a lot less
than the 5,000 milliseconds delay
we saw with the regional load balancer.
STEPHANIE WONG: In our regional load balancer test,
we saw the load balancer became overloaded when traffic
increased past capacity.
PRIYANKA VERGADIA: This is what tends
to happen with typical on-premise load balancers,
or when using the standard tier network on regional https load
balancers.
STEPHANIE WONG: The request latencies
increased by more than 10x.
PRIYANKA VERGADIA: Meanwhile, using the global https load
balancing setup lets your traffic overflow
to the next closest region with available serving capacity.
You have lower increase in end user latency,
and a better user experience, meaning--
STEPHANIE WONG: Beyond Treats' customers will still
be able to order pumpkin pie, flax buscuits, peanut butter
treats, and carrot cakes on National Dog Day.
No full service outages when traffic spikes.
PRIYANKA VERGADIA: For more information
about GCP's global load balancing
optimizing application latency, check out the documentation
in the link below.
STEPHANIE WONG: That's all for today on Get Cooking in Cloud.
Here's hoping you are whipping up your own capacity management
with Cloud load balancers.
PRIYANKA VERGADIA: If you liked this video
and would like to see more such content,
don't forget to like and subscribe to our channel.
[MUSIC PLAYING]