SPEAKER: Hello, and welcome to this episode of the Apigee
Accelerator Series.
In this video, you'll see how to improve an API's performance
by leveraging Apigee's built in caching policies
to improve response times, lower costs, or decrease
load on your backend services while still
being able to scale.
Let's take a high-level look at how this works
with a cache response policy.
Say you have Apigee in front of your API,
and the request comes in.
If the response from the API is not in the cache,
the request will be forwarded to the target backend.
Once a response is received, it is
placed into the cache using the key of your choosing
and forwarded to the API client.
On subsequent requests, if the cache lookup succeeds,
the response is sent immediately to the API client
without placing additional load on the target backend.
Now that you've seen the high-level overview,
let's see how to deploy the accelerator.
In order to run this sample, you need
to have an Apigee X instance provisioned
with access configured for external traffic.
And, as a user, you'll need to have access
to deploy the API proxies.
This can be granted using either the API Admin or Org Admin
roles.
And lastly, to deploy the sample,
you'll need the command line tool shown here.
Good news is that if you're using Google Cloud Shell,
these are already installed.
This sample can be demonstrated using either the Cloud Shell
Quickstart tutorial or following the setup instructions.
In this video, we'll use the Cloud Shell Quickstart.
Click Open in Google Cloud Shell to open the Cloud Shell
environment.
Once the environment is loaded, let's follow the instructions
provided in the tutorial.
First, you will want to make sure that you
log in using the right account.
Then, we'll navigate to the right folder
and then open the env.sh file.
There, we're going to set the environment variables
to reference your Apigee project, the target
environment, and the external host name.
Next, run the included script to deploy the sample
to your Apigee instance.
This will take about a minute to complete.
Once it completes, you'll see a message with the API proxy URL.
Now, to test the effects of caching,
we'll run a curl command that outputs the total response
time.
Take note of the total time from the first request.
We'll run the same request a subsequent time.
This time, the request will be served from cache,
as can be seen by the lower response time--
almost 10x faster in my instance.
All right, now that you've seen this policy in action,
let's take a look at how this is configured in Apigee.
In a new tab, open the API Management UI.
You can navigate to it from the Google Cloud Console
by searching for Apigee in the search bar.
In the API Proxies page, you should see the basic caching
proxy.
Select the proxy and go to the Develop tab.
You'll see several policies, but the one
you're interested in right now is the Response Cache Policy.
This is where you configure the cache
key to use, how long the item should remain in the cache,
and conditions for which you should skip
looking up an item from the cache
or placing an item into the cache.
When you're done with this sample,
you can switch back to the Cloud Shell Editor
to provide us feedback and to use the cleanup script
to delete the configuration that was deployed to your Apigee
instance.
Thanks for watching.
I hope this content was useful to you.
If you have not signed up for Apigee yet, use this link.
If you have any questions, please
visit the Apigee Community and subscribe
to our channel to see more videos in the Apigee
Accelerator Series.