GICT knowledge base
How to Monitor and Reduce Server Costs on Cloud Providers
Published
Cloud bills have a way of growing quietly. You spin up a few servers, attach some storage, add a load balancer, and six months later the monthly invoice is twice what you expected. The problem is rarely one expensive resource. It is usually dozens of small things adding up, most of which nobody is watching.
In this article, you will learn how to monitor cloud spending across providers, identify the resources that quietly drain your budget, and apply practical changes that cut costs without breaking your applications. The techniques here work whether you run a single virtual machine or a fleet of hundreds.
Prerequisites
Before you start, make sure you have:
- An active account with at least one cloud provider.
- Administrative or billing-level access to view cost reports.
- A basic understanding of the resources your account currently runs.
- Command-line access to a Linux machine for running monitoring scripts.
Why Cloud Bills Get Out of Control
Cloud pricing looks simple on the surface. You pay for what you use. The problem is that “what you use” includes a lot of things people forget about. A virtual machine has compute charges, but it also has storage charges, snapshot charges, network egress charges, and sometimes Internet Protocol (IP) address charges when it is not running. A managed database has hourly costs plus storage plus backups plus data transfer.
The other issue is that nobody deletes things. A developer spins up a test server, finishes the work, and moves on. The server keeps running. Multiply that by a dozen developers over a year, and you have a meaningful chunk of your bill going to nothing.
The third issue is overprovisioning. Servers are usually sized for peak load, but most servers spend most of their time well below peak. You end up paying for capacity that sits idle.
Cost reduction is mostly about visibility. Once you can see where the money goes, the fixes are usually obvious.
Set Up Billing Alerts First
Before you do anything else, set up billing alerts. This is the single most valuable thing you can do, and it takes about ten minutes.
Most cloud providers let you create alerts that trigger when spending crosses a threshold. The point is not to stop the bill, since you cannot really cap spending without breaking running services. The point is to know early when something has gone wrong.
A common pattern is to set three alerts. One at 50 percent of expected monthly spend, one at 80 percent, and one at 100 percent. The first one tells you spending is on track. The second one warns you that the month is running hotter than usual. The third one tells you something needs immediate attention.
[!NOTE] Billing data on most cloud providers updates with a delay of several hours. Alerts will not catch a runaway resource the moment it starts costing money, but they catch it before it ruins your week.
Monitor Resource Usage on Linux Servers
Cloud provider dashboards show you cost. They do not show you whether the resource is doing anything useful. For that, you need to look at the server itself.
Check CPU and Memory Utilization
A server running at 5 percent Central Processing Unit (CPU) for weeks is a server that is too big for its job.
Check current CPU and memory usage.
top
The header shows load averages and memory totals. Press q to exit.
Get a longer view of CPU usage.
sar -u 5 12
The command samples CPU usage every 5 seconds for a minute. If the sar command is missing, install the sysstat package.
sudo apt install sysstat
Check memory usage in a more readable format.
free -h
Look at the used column under Mem. If a server has 8 GB of RAM and consistently uses 1 GB, you can probably drop down to a smaller plan.
Check Disk Usage
Disk is the silent budget killer. Storage is cheap per gigabyte, but it adds up across many servers and snapshots.
Check total disk usage.
df -h
The output shows mounted filesystems, total space, used space, and available space. Pay attention to anything more than 80 percent full or wildly underused.
Find the biggest directories on a server.
sudo du -h --max-depth=1 / | sort -hr | head -20
The command lists the 20 largest directories under root. Logs and old backups are common culprits.
Look for large files specifically.
sudo find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null
Files over 100 MB show up here. Old database dumps, forgotten log archives, and core dumps from crashed processes often turn up.
Identify Idle and Underused Resources
Once you can see what each server is doing, the next step is finding the ones that are doing nothing.
Stopped Instances Still Cost Money
Many cloud providers continue charging for storage, IP addresses, and reserved capacity even when an instance is stopped. A stopped server is not a free server.
Go through your account and look for instances that have been stopped for more than a week. If you genuinely need them, fine. If they are leftovers from a project that ended, terminate them. The data on the disk is gone, but the cost is gone too.
Unattached Volumes
When you delete a virtual machine, the attached storage volume sometimes stays behind, depending on the provider’s settings. These orphaned volumes keep billing month after month, and nobody notices because nothing is using them.
Check your storage section for volumes with no attachment. If you do not recognize them, snapshot the ones that look important and delete the rest.
Old Snapshots and Backups
Snapshots are cheap individually and expensive collectively. A development team that takes daily snapshots and never deletes them ends up with hundreds of snapshots from servers that no longer exist.
Set a snapshot retention policy. For most workloads, keeping daily snapshots for two weeks and weekly snapshots for two months is plenty. Anything older is unlikely to be useful.
Floating IP Addresses
Most cloud providers charge for floating or reserved IP addresses that are not attached to a running instance. These charges are small per address but add up if you have dozens of unused ones sitting in the account.
Right-Sizing Your Servers
Right-sizing is the process of matching server specs to actual workload. Most servers are bigger than they need to be because somebody picked a plan size at the start and never revisited it.
The general approach is to monitor CPU and memory usage over a representative period, usually two to four weeks, then drop down to the smallest plan that still handles peak load with reasonable headroom.
A useful rule of thumb is the 40 percent rule. If a server’s average CPU usage is below 40 percent and peak usage stays below 70 percent, you can probably move down a tier. The savings from one tier is usually 30 to 50 percent of the original cost.
[!WARNING] Always test right-sizing changes during low-traffic periods. A plan that looks fine on average might struggle with traffic spikes you did not capture in the monitoring window.
Use Reserved Instances and Committed Use Discounts
Most major cloud providers offer significant discounts in exchange for commitments. The discounts range from 20 to 70 percent depending on the term length and how much you commit to.
These commitments make sense for any workload that runs continuously and predictably. A production database, a primary application server, a reverse proxy. These are good candidates because they will run for the next year or three regardless.
Avoid committing to capacity for development environments, batch jobs, or anything that might get rearchitected soon. The discount is not worth being locked in if you change direction.
Reduce Network Transfer Costs
Network egress, meaning data leaving the cloud provider’s network, is where surprise charges often hide. Inbound traffic is usually free. Internal traffic between resources in the same region is usually free or very cheap. Data leaving the region or the provider entirely costs real money.
A few practical reductions:
- Keep services in the same region. A web server in one region talking to a database in another region pays egress charges for every query.
- Use a Content Delivery Network (CDN) for static assets. Serving images, CSS, and JavaScript from the origin server burns through egress quickly. A CDN caches at the edge and dramatically reduces traffic from the origin.
- Compress responses. Enabling gzip or Brotli compression in your web server cuts response size by 60 to 80 percent for text-based content.
- Watch for noisy logging integrations. Sending every application log to a third-party service over the network can generate surprising amounts of egress.
Schedule Non-Production Workloads
Development, staging, and Quality Assurance (QA) environments rarely need to run 24 hours a day. A typical work week is roughly 40 hours. Running development servers continuously means paying for 168 hours when you only use 40.
Setting up automated start and stop schedules can cut non-production costs by 60 to 75 percent. Most providers have built-in scheduling features or can be controlled with a simple cron job and Application Programming Interface (API) calls.
Create a basic scheduling script.
nano ~/scripts/stop-dev-servers.sh
Add the appropriate API calls for your provider. The general pattern is to authenticate, list the instances tagged as development, and stop each one.
Schedule the script with cron to run at 8 PM on weekdays.
crontab -e
Add a line like this.
0 20 * * 1-5 /home/user/scripts/stop-dev-servers.sh
Add a corresponding start script for 8 AM on weekdays.
0 8 * * 1-5 /home/user/scripts/start-dev-servers.sh
The exact API calls vary by provider, but the principle is universal. If a server is not being used, it should not be running.
Audit Managed Services
Managed services like databases, load balancers, and Kubernetes clusters cost more than running the equivalent yourself, and the convenience is usually worth it. But the same overprovisioning problems apply.
Look at managed databases especially. The default plan size is often larger than what the workload needs. A 2-core managed database running at 10 percent CPU is probably oversized. Drop it to a smaller plan and watch performance for a week.
Load balancers and Kubernetes control planes have fixed costs even when they handle no traffic. If you have load balancers attached to projects that are no longer active, delete them.
Build a Monthly Cost Review Habit
The single best long-term cost control technique is just looking at the bill every month. Not glancing at the total, but actually opening the cost breakdown and reading it.
A useful monthly review covers:
- Which resources increased in cost compared to last month.
- Any new charges that did not appear before.
- Resources that have been running for a long time without recent activity.
- Whether the previous month’s optimizations actually reduced spending.
This takes about thirty minutes once you get into the habit. Most cost overruns happen because nobody is paying attention. A regular review fixes that.
Conclusion
You now know how to monitor cloud spending, find idle and underused resources, right-size servers, take advantage of commitment discounts, reduce network costs, and schedule non-production environments to run only when needed. Each of these techniques saves money on its own, but they work best together.
Cloud cost management is not a one-time project. It is an ongoing practice. Set up billing alerts today, audit your account this week, and put a recurring monthly review on your calendar. The bill will not shrink by itself, but with steady attention it tends to drop faster than people expect.
