How Much Performance Does Your Cloud Server Really Need?

cpu designagsandrew / Shutterstock

Most cloud providers divide their offerings by the number of processor cores and the amount of RAM. Do you need a large multi-core server, or an entire fleet of them? Here’s how to measure your server’s actual performance.

Does your application need to “evolve”?

It is very common for technology startups to be attracted to a “scalable” architecture, that is to say that you build your server architecture so that each component of it can evolve to respond to any amount of request.

It’s great and all, but if you don’t experience this amount of real-world traffic, it can be overkill (and more expensive) to build a scalable architecture with the intention of increasing up to a million. users if you only manage a few thousand.

You will want to favor the creation of a good application over the creation of an exceptional infrastructure. Most applications work surprisingly well with just a few standard servers that are easy to manage. And, if your application is successful, your growth will likely occur over the course of a few months, giving you enough time (and money) to work on your infrastructure.

A scalable architecture is always a good thing to build, especially on services like AWS where automatic scaling can be used to reduce and save money during off-peak hours.

RELATED: How to Speed ​​Up a Slow Website

You have to plan the peak load

The most important thing to keep in mind is that you are not planning around the average load, you are planning around the peak load. If your servers cannot handle your peak load during midday, they have not achieved their goal. You need to make sure that you measure and understand the load on your server over time, rather than just looking at CPU usage in a single instant.

Evolutionary architecture is useful here. Being able to quickly run a spot instance (which is often much cheaper) to lighten some of the load on your main servers is a very good design paradigm and allows you to significantly reduce costs. After all, if you only need two servers for a few hours a day, why pay to run it overnight?

Most large cloud providers also have scalable solutions for containers like Docker, which allows you to scale things up automatically, because your infrastructure can be duplicated more easily.

RELATED: What does Docker do and when should you use it?

How is your server performing?

It is a difficult question to answer exactly; everyone’s apps and websites are different, and everyone’s server hosting is different. We cannot give you an exact answer on the server that best fits your use case.

What we can do is tell you how to do it for yourself to experience what works best for your particular application. This involves running your application under real conditions and measuring certain factors to determine if you are overloaded or underloaded.

If your application is overloaded, you can run a second server and use a load balancer to balance traffic between them, like AWS Elastic load balancer or quickly Load balancing service. If it is significantly underloaded, you may be able to save a few dollars by renting a cheaper server.

CPU usage

CPU usage is probably the most useful measure to consider. It gives you a general overview of your server overload; if your processor usage is too high, server operations may stop.

The processor usage is visible at the top and the load averages for the last 1, 5 and 15 minutes are also visible. It gets this data from / proc / loadavg /, so you can save it to a CSV file and graph it in Excel if you want.

Most cloud providers will however have a much better graph for this. AWS a CloudWatch, which displays the processor usage for each instance under the EC2 metrics:

Processor usage graph.

Google Cloud Platform displays a nice graph under the “Monitoring” tab in the instance information:

In both graphs, you can adjust the time scales to display processor usage over time. If this graph consistently reaches 100%, you may want to study the upgrade.

Keep in mind, however, that if your server has multiple cores, the CPU usage may still be “overloaded” while the graph is far from 100%. If your CPU usage is nearly 50% pinned and you have a dual core server, it is likely that your application is mainly single threaded and sees no performance advantage.

RAM usage

RAM usage is less likely to fluctuate a lot, as the main question is whether you have enough to do a certain task.

You can quickly display the memory usage at the top, which displays the memory currently allocated for each process in the “RES” column, as well as the display of the percentage usage of the total memory in the “% MEM” column. “

You can press Shift + M to sort by% MEM, which lists the most memory-intensive processes.

Note, memory speed affects processor speed to some extent, but it’s probably not the limiting factor unless you’re running an application that requires bare metal and the fastest possible speeds.

Storage space

If your server runs out of space, it can block certain processes. You can check the disk usage with:

df -H

This displays a list of all the devices connected to your instance, some of which may not be useful to you. Look for the bigger one (probably / dev / sda1 /), and you can see how much is currently in use.

Current amount of disk space used.

You need to use log rotation efficiently and make sure that nothing creates excess files on your system. If so, you may want to limit it to storing only the latest files. You can delete old files using find with time parameters, attached to a cron job that runs once an hour:

0 * * * * find ~ / backups / -type f -mmin +90 -exec rm -f {} ;

This script deletes all files in the ~ / backups / folder older than 90 minutes (used for a Minecraft server that made backups of 1 GB + every 15 minutes, filling a 16 GB SSD). You can also use logrotate, which achieves the same effect more elegantly than this hastily written command.

If you store a ton of files, you might consider moving them to a managed storage service like S3. It will be cheaper than having disks connected to your instance.

RELATED: How to configure Logrotate on Linux (to prevent your server from running out of space)

Network speed

There’s not a great way to monitor this natively, so if you want to get good command line output, install sar from sysstat:

sudo apt-get install sysstat

Activate it by editing / etc / default / sysstat and setting “ENABLED” to true.

This monitors your system and generates a report every 10 minutes, running them once a day. You can modify this behavior by modifying the sysstat crontab in /etc/cron.d/sysstat.

You can collect them as an average of network traffic with the -n flag:

sar -n DEV 1 6

The, direct it to the tail for a more pleasant outing:

sar -n DEV 1 6 | tail -n3

It displays an average of packets and kilobytes sent per second on each network interface.

It is however easier to use a graphical interface for this; CloudWatch has a “NetworkIn” and “NetworkOut” statistic for each instance:

You can add a dynamic label with a SUM function, which displays the total network in bytes for a given period of time.

It is difficult to judge whether or not you overload your network; most of the time, you are limited by other factors, such as whether or not your server can respond to requests, before you worry about bandwidth usage.

If you’re really concerned about traffic or want to stream large files, you should consider getting a CDN. A CDN can lighten the load on your server and allow you to serve static media very efficiently.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.