Many people will immediately attribute a noticeable slowdown with their computer to an aging and failing hard drive, but that’s not always the case. Even desktops and notebooks that aren’t particularly old can start to have performance shortcomings, and it’s not like most of us have the means to simply replace our devices every time this occurs. Adding to this issue is the fact that modern life is demanding that we demand more for those devices too, and this makes it so that our personal and work computers are often overloaded in ways.
This trend isn’t lost on anyone we imagine, and here at 4GoodHosting one of the things we’re very aware of as a Canadian web hosting provider is that anyone who has a website is going to be wary of a high bounce rate. If you don’t know what that is, it’s the rate at which visitors to your site leave within a certain time period of their arrival. Would-be visitors to your site who perceive some sort of problem with it opening and displaying may put that on you, when in fact it has much more to do with the shortcoming of their browser device of-choice.
The good news is that there are ways to optimize CPI usage and performance, and a good many of them aren’t going to ask much in the way of your time, effort, or expense. So let’s have a look at those with our blog post for this week.
All About Throughput
The way it works for most applications is that performance is centered around throughput. The definition for that term is how much work the server can process in a certain timeframe.
Nowadays most high-end servers on the market are designed with throughput in mind.
Finding just one server that’s ideally optimized for running all types of workloads out-of-the-box hasn’t happened yet, however. So getting the most out of your server’s available resources is best done by the CPU’s physical limitations relative to your performance requirements.
Understanding that all CPU optimization efforts are essentially software-based is a good place to start. So rather than upgrading hardware, it’s better to focus on your workload or other software running on the machine. Better server performance is often about tradeoffs – optimizing one aspect of the server at the expense of another.
Clarify Performance Objectives
We can start with this; when you increase the size of the cache the overall processing speed will increase along with it, but that results in higher memory consumption. So while this approach most people would take by default, it’s not the fix most of you will hope it to be.
Understanding and being responsive to workloads running on it has the be a part of the analysis and response too.
Since each workload is unique and consumes resources differently, there are no fixed rules for defining hardware requirements or performance targets. SQL database workloads, for example, are heavy on the CPU while 3D rendering workloads gobble up high amounts of memory.
So in advance of deploying or configuring your server infrastructure, you should start by assessing your requirements, and that’s best done through what’s called ‘capacity planning.’ Doing so gives you insight into your current resource usage and - done right - guides you to developing optimization strategies for existing and future performance expectations.
As this relates to common types of workloads likedatabase processing, app or web hosting, here’s what you should be looking at and evaluating for CPU performance objectives:
- What number of anticipated users do you expect to be using your application?
- What is the size of an average single request?
- How many requests do you expect during average load and spikes in demand?
- What is the desired SLA? (defined as periods of measure time)
- Can you establish target CPU usage?
You should determine which server components your application relies on the most too, understanding that;
- Performance/throughput is CPU based
- Memory consumption is RAM based
- Latencyis network based
- I/O operationsis disk based
Optimizing for performance is also very much related to the the number of CPU cores, and this is likely something that a layperson will be able to understand more readily. Long story shorter, a multi-core processor is going to be a lot more usable for multi-threaded jobs. Without one you may find yourself dealing with a high CPU wait time, which is going to be pretty much intolerable for anyone and everyone.
Storage configurations are a factor too; and certain ones will have negative impacts on performance. Having the right disk type and properly configured storage resources decreases latency. If you are running latency-sensitive workloads such as database processing, this becomes something you’ll really want to pay attention to. Such workloads need to be optimized to utilize memory resources efficiently.
Here’s some connections you can make regarding all of this:
- CPU-intensive workloads: machine learning, high-traffic servers, video encoding, algorithmic calculations
- Memory-hungry workloads: SQL databases, CGI rendering, real-time big data processing
- Latency-sensitive workloads: video streaming, search engines, and mobile text message processing
Keep Tabs on Resource Usage
Here’s a fairly ubiquitous equation that will apply to pretty much everyone; When usage exceeds 80% of the CPU’s physical resources, applications begin to load slower or the server may no longer respond to requests.
So what sorts of actions take CPU usage up to those levels? A common scenario is if a database server uses 100% of the CPU capacities then that might be the result of the application running too many processor-intensive tasks such as sorting queries. To decrease the load, you would have to optimize your SQL queries to utilize available resources more efficiently.
High CPU usage could also be attributed to poorly coded applications, outdated software, or security vulnerabilities. The only way to precisely determine the root cause of performance issues or bottlenecks is to use analytics and monitoring tools.
Generally speaking, CPU utilization should never be at full capacity. When an application is consuming 100% of the total processing power under average load, the CPU will be unable to handle sudden demand spikes, and that means latency or service unavailability.
Stay Under 80
Having latency-sensitive applications utilizing no more than 80% of the CPU’s power is a general good-practice guideline. Applications that are less sensitive to latency may allow CPU utilization up to 90%. Be judicious about how you determine that though, and don’t be forgiving.
To mitigate high CPU usage issues, common solutions include optimizing your application’s code, limiting the number of requests, optimizing the kernel or operating system processes, or offloading the workload to additional servers.
One last mention on this topic is programming languages. The programming language running your application also factors into CPU usage. Programming languages that run close to the metal, such as C or C++, provide more control over hardware operations than compiled languages such as Python or PHP. Writing applications in C or C++ is advantageous this way, and particularly if you need granular control over how your application consumes CPU and memory resources.