In the cloud, it's important to look regularly and closely at how your applications and services are architected and utilized. It's the best way to identify opportunities that will let you right-size your instances, fine tune your databases, modify your storage usage, better configure your load balancers, or even re-architect your applications.
For example, if you have a set of 20 instances all running at 10% CPU usage, you might consider using smaller instances or consolidating more work onto those instances. This kind of thinking about your cloud utilization and spend will help you optimize your environment and save money quickly.
Optimizing your cloud architecture has three main goals:
Improve performance, availability, and end-user experience by taking better advantage of cloud services
Optimize your cloud spend, striking the delicate balance between cost and performance
Capture business and technical metrics that help justify your current cloud spend that can be referenced as justification for a larger cloud budget as growth dictates
In this tutorial, we'll show you how to use the New Relic platform to capture all the data you should leverage to optimize your cloud architecture and spend.
1. Instrument your application and cloud environment
Make sure the following products and integrations are instrumented:
|Install New Relic Infrastructure||
Instrument infrastructure: If you haven't already done so, review the requirements for the New Relic Infrastructure agent. Infrastructure comes with several types of integrations, including Amazon Web Services (AWS), Microsoft Azure, and on-host integrations. After you've installed the Infrastructure agent on your host(s), you'll immediately have access to the broad spectrum of metrics the agent collects out-of-the-box.
|Install the APM agent||
Instrument your applications with New Relic APM. Doing so will let you monitor how your applications are performing while you are optimizing the underlying cloud services. That way, you can confirm that your changes to the infrastructure are in fact improving application performance.
|Configure the AWS integration||New Relic Infrastructure's Amazon integrations let you monitor your AWS data in several New Relic products, including Infrastructure, New Relic Insights, and New Relic Alerts.|
|Connect AWS Billing||If you are hosted in an AWS environment, New Relic can help you monitor your cloud spend with our AWS Billing integration. To leverage New Relic's AWS Billing integration, follow the procedures in the Connect AWS Billing documentation|
2. Create dashboards to display baseline infrastructure metrics; include AWS budgets if available
New Relic Insights lets you write powerful custom queries about your data and visualize the results in widgets displayed on a common dashboard. You can also feed the results of your New Relic Insights queries directly into New Relic Alerts, where you can get immediate notifications on any deviation identified.
For this step, you should display baseline infrastructure metrics related to performance and usage (CPU, memory, disk, database, etc.). Include AWS Budgets if available. To get you started, here are ways to use Insights dashboards to visualize your AWS cloud utilization and spend data:
- Create dashboards for each level of your organization
Whether you're a developer, operator, or executive, having information about your cloud utilization can help you optimize your cloud environment:
Developers: Understanding what applications currently cost can help developers configure applications to use more services more efficiently. For example, could developers cut cloud costs using AWS Lambda or properly sized instances?
Operators: Monitoring application utilization allows operators to catch possible overruns due to mis-configured services. For example, is the ops team's auto-scaling configuration scaling down properly?
Executives: An overall view of both fore-casted and actual cloud spend, for individual applications, per region, and overall totals, can help executives make better business decisions.
Use New Relic to keep track of your cloud spend, and make sure your teams get alerted immediately when you exceed thresholds.
3. Identify resources for optimization
This step shows you how to use the metrics New Relic has captured to determine which resources to optimize.
In the sample dashboard above, the CPU-usage widget on the left reveals that this application uses many instances sizes. Note that the “c4.xlarge” instance (in coral) consistently consumes only around 20% CPU capacity. However, when you analyze the c4.xlarge Memory usage in the center widget (light green), you'll see that memory usage for this instance ranges from 20% to 80%. This suggests that the application is more memory-intensive than CPU-intensive. In this case, the instance type should be changed from a compute-optimized instance to one that is memory-optimized. (Note: the chart on the right of the dashboard can be used to monitor the application's average response time as you make these optimizations.)
This is just one example of how to identify cloud-based resources that could be candidates for optimization.
Now that you've identified architecture for optimization, go ahead and do so. Whether you right-size your instances, fine tune your databases, modify your storage usage, better configure your load balancers, or even re-architect your applications, in the end your goal is to be able to compare your new, optimized architecture against the baselines you captured in Step 2. For more about baselines please review the Establish Objectives & Baselines tutorial.
4. Optional: Set up alerts
You can create an alert condition for NRQL queries. Be sure to reference the complete documentation as needed.
In the data app for the AWS production budget introduced in Step 2, this was one of the widgets:
Here is the query that we used to create that widget:
SELECT latest(`provider.actualAmount`) as '$ Actual', latest(`provider.forecastedAmount`) as '$ Forecast', max(`provider.limitAmount`) as '$ Limit' FROM FinanceSample WHERE provider = 'BillingBudget' AND `provider.budgetName` = '[Your Cloud Budget]'
If you can write queries on your data and show them in Insights, then you can easily use them to generate Alert conditions.
New Relic also lets you write “baseline queries” against your data. These are queriesy you write without setting hard limits on the results. Rather, you let New Relic Applied Intelligence “machine-learn” your performance data, and then alert you when your data strays too far outside of your baseline numbers.
To create a baseline query, head over the the Alert console, go into Alert policies, and add a New alert policy. Then follow these steps:
Create alert policy. Give your policy a concise and descriptive name and select an Incident Preference. Then select Create alert policy.
Create a condition. Select NRQL
Define your query, and decide how restrictively Applied Intelligence should analyze your data using a simple slider and visualization based on your recent performance.
Using New Relic Applied Intelligence is a great way to help you proactively learn about your cloud spending or about any of your performance data.
For a quick primer on the New Relic platform, check out Learn the New Relic Digital Intelligence Platform in 30 Minutes or Less.
Review the Proactive alerting and incident orchestration tutorial for a deeper dive on some of the best practices outlined above.