🏢

Isolating Resource Usage by Customer in Multi-Tenant Hosting

· Server Scout

A customer calls at 3 AM claiming their website is "completely broken" whilst your monitoring dashboard shows the server running perfectly fine. CPU at 12%, memory at 40%, disk space healthy. Yet their WordPress site is indeed crawling at 30-second page loads.

This is the multi-tenant monitoring problem. Traditional server metrics tell you the forest is healthy whilst individual trees are on fire.

The cgroups Approach

Linux cgroups v2 provides the most reliable foundation for per-customer resource tracking. Instead of trying to retroactively map processes to customers, you constrain and monitor resources at the container or service level from the start.

For cPanel environments, each user already runs under their own UID. You can create cgroups for each customer and track their resource consumption independently:

# Create customer-specific cgroup
sudo mkdir -p /sys/fs/cgroup/customers/customer123
echo "1000" > /sys/fs/cgroup/customers/customer123/cgroup.procs

The beauty of this approach is that resource limits and monitoring happen in the same place. Set a 2GB memory limit for a customer, and you'll get precise alerts when they approach that threshold rather than waiting for the entire server to hit swap.

Process Attribution Without cgroups

Not every hosting environment can restructure around cgroups. For traditional setups, you need process-to-customer mapping based on ownership, working directories, or command arguments.

A simple approach tracks processes by their effective UID and maps these to customer accounts. Combined with regular snapshots of /proc//stat and /proc//status, you can build historical resource usage per customer.

The trick is handling short-lived processes. A customer's PHP script might spawn dozens of processes that exist for milliseconds. Point-in-time sampling misses these entirely, but they can consume significant CPU over time.

Smart Alerting for Multi-Tenant Environments

Standard server alerts become useless in multi-tenant setups. A 70% memory alert might fire because one customer is running a memory leak, whilst 19 other customers experience no issues.

You need dual-threshold alerting: per-customer limits based on their allocated resources, plus aggregate server limits for genuine hardware issues. When customer A hits 90% of their 1GB allocation, that's a customer-specific alert. When the server hits 90% of total RAM, that's an infrastructure alert.

Similarly, disk space monitoring needs to track both per-customer usage against quotas and overall filesystem health. A customer filling their allocated 10GB shouldn't trigger the same response as the root filesystem hitting capacity.

Implementation Challenges

The biggest challenge is data volume. Tracking detailed metrics for hundreds of customers generates substantial monitoring overhead. You need efficient storage and smart aggregation.

Consider tracking high-resolution metrics (every 10 seconds) only for customers currently experiencing issues, whilst maintaining lower-resolution baseline metrics (every 5 minutes) for everyone else.

Network I/O attribution remains particularly tricky. Associating network connections with specific customers requires either deep packet inspection or careful tracking of socket ownership, both of which add complexity.

Making It Practical

Start simple: track CPU time and memory usage by UID, set basic per-customer thresholds, and build alerting around quota violations rather than absolute resource levels.

The monitoring infrastructure needs to handle the increased metric volume without becoming a performance bottleneck itself. Look for solutions that can process customer-specific metrics efficiently rather than treating every data point identically.

Multi-tenant monitoring transforms reactive firefighting into proactive customer management. Instead of discovering problems during angry phone calls, you can identify resource-hungry customers before they impact others and have data-driven conversations about upgrade requirements.

Server Scout's plugin system handles custom metric collection for multi-tenant scenarios, letting you track per-customer resources without heavyweight agent overhead.

Ready to Try Server Scout?

Start monitoring your servers and infrastructure in under 60 seconds. Free for 3 months.

Start Free Trial