Cost Optimization Strategies
At Staq, we prioritize transparency and provide tools and alerts to help you manage costs effectively. While this guide will not eliminate all overage costs—particularly for resource-intensive websites—it will help identify opportunities to reduce expenses across various categories.
Cost Categories
This guide evaluates costs in the following categories:
- Visits
- Bandwidth
- Local Storage
- Database Storage
- CPU Usage
- Memory & PHP Workers
Below, you’ll find recommendations specific to each category.
Visitors
Staq tracks unique visitors at the server level. To reduce overage costs, cache your website using CDN options available in the Staq Panel for the site. Visitors served via a CDN are not counted against your visitor quota, as visitor traffic is based on server hits.
CDN Options
Staq supports the following CDN solutions:
- Staq Next-Gen CDN (requires using Staq DNS)
- Cloudflare
For guidance on enabling CDNs:
Bandwidth
Bandwidth optimization involves several strategies:
Enable Lazyload
Lazyload prevents loading all page media until users scroll to view specific sections.
WP Rocket
- Go to WP Rocket > Media and enable:
- Lazyload for images
- Lazyload for CSS background images
- Lazyload for iframes and videos
Staq Cache
Go to Staq Hosting > Optimizer > Media, then enable Lazyload images & videos.
Compress Images (Staq Hosting)
AWS Cloud Integration
Ensure Rewrite media URLs is enabled in Staq Hosting > AWS Cloud.
Optimizer Settings
In Staq Hosting > Optimizer > Media, enable:
- Rewrite media URLs
- Serve next-gen images (WebP)
Note: If you use Cloudflare, these settings do not apply. A server-based image compression feature will be available by January 2025.
Check Bandwidth Metrics
In the site’s Staq Panel > Metrics > Traffic & Storage, check:
- Amazon EC2 bandwidth
- Amazon S3 outgoing bandwidth
- Amazon CloudFront bandwidth
Evaluate whether S3 bandwidth significantly exceeds EC2 bandwidth. If yes, optimizations may be limited for images.
Compress Images – Third Party
You can use a third party image compression tool to reduce images but this will be irrelevant from January 2025 if you have Cloudflare enabled.
Compress or Offload Videos
Use tools like Veed to compress videos. Alternatively, host large videos on platforms like Vimeo or YouTube to minimize bandwidth.
Push to Cloudflare
Integrate Cloudflare to serve assets like images via CDN. This traffic does not count toward Staq bandwidth. Follow this guide: Cloudflare integration.
Local Storage
High storage usage on small websites is often due to third-party backup files. Staq backups stored on AWS S3 do not count toward storage limits. To free up space:
- Use sFTP access to check for backups, such as:
.zipfiles in the root directory.wpressfiles inai1wm-backups(insidewp-content)updraftfiles inwp-content
Delete unnecessary backups or files to reduce storage costs.
Database Storage
Optimize your database using the Advanced Database Cleaner plugin. It removes expired transients, orphaned metadata, and unnecessary entries.
Check for large tables like wp_woocommerce_log and clear unnecessary entries.
CPU Usage
High CPU usage may indicate an issue, especially for non-resource-intensive websites.
Investigating Spikes
Go to Staq Panel > Metrics > PHP Workers and check data over the last 30 days. Identify spikes or consistent high usage.
Optimize Cron Jobs
Install WP Crontrol plugin inside WordPress to identify problematic cron jobs. A common offender is action_scheduler_run_queue, which runs every minute. Reduce its frequency to lower CPU usage.
Memory & PHP Workers
Memory
Check and adjust PHP memory limits:
- Go to Staq Panel > PHP Config and review Request Memory Limit.
- Go to Metrics > PHP Workers, select Daily > 30 days, and check if memory usage exceeded 256MB.
If not, consider downsizing the memory allocation.
PHP Workers
Similarly, under Metrics > PHP Workers, review Parallel PHP Workers. If the usage consistently stays below the limit, reduce the number of PHP workers.
By applying these strategies, you can manage and optimize costs effectively across your hosted sites.
Need some help?
We all do sometimes. Please reach out to our support team by dropping us a support ticket. We will respond fast.