You may have noticed on lower cost services, visitors experience consistent slow response times or intermittent timeouts viewing a page, or, as an editor, impossible situations building large web pages, and consistent inability to edit pages. These are memory resources issues.

The problem is compounded when adding multiple domains to the same service, or when other users of the hardware hammer it.

The basic issue is with how the system is configured for available memory resources. If these resources are naturally maxed out, one has to purchase another hosting plan that gives more memory and CPU. We can use various tools to see if this is a fundamental problem.

Some folks cannot afford a higher tiered plan and put up with these bad frustrations. The problem never goes away. This is not a good place to be.

We may overcome this limitation by migrating to a virtual private server on an Amazon AWS Linux platform. The tradeoff is to ensure e-mail is a genuine business-level service, and that you no longer have a classic cPanel graphical interface. This means you cannot maintain the service yourself, (unless you are a Linux person)  and therefore rely on a service, in this case  Advantage Web or a Web Developer offering Linux support, to keep your system healthy with a low maintenance fee as needed.

AWeb from time to time does good will routine maintenance for all clients without a fee.

Memory is divided up or shared between the services that request it. This will have prioritised chunks of allocated memory, and there is not too much we can do about it. Basically, give me fifty percent of the lamb roast and the rest has to be divided to others, so go away, and do not touch mine! Or, we cut up the lamb roast and let everyone fight over it. This is fine if we have enough lamb roast and people to give it to. (Apologies to those who are vegetarian – like my Mum.)

When we edit a WordPress site, we use more PHP allocated memory than simply viewing the page. A large home page can max out below 500MB RAM, meaning WordPress needs a lot. Add multiple domains, and those WordPress sites become active.

Even though the operating system knows to move temporary content back and forth to swap disk space when RAM memory is too high, it can still build up pressure and at some point fail. If the demands on swap disk space sky rocket, it is like an old car constantly stopping and starting with aggressive jerking movements. Commercial default configurations, generally the same for everyone, can mean slower performance than what one could have within the bounds of the system, or bad runaway processes that clock up the resources on high steroids!

We can observe a potential severity of resource configurations by opening up several WordPress pages, editing all of them, and observe if the save times and editing becomes slower and slower, coupled with a review of the CPU/RAM statistics. After resources are given a breather, they should go back to a normal baseline, rather than remaining maxed out. These are issues around the operating system releasing memory, or memory being adversely and permanently leaked. Regardless, it is helpful to automatically restart services each night via Linux commands that do not prevent or break current visitor transactions.

If for some reason the resources are all guzzled up, we want to examine error logs to find the source, then ensure services are automatically restarted so visitors do not call you a day or so later wondering why they cannot get onto your site. In these scenarios, we want an e-mail notification of a problem. These frightmares are able to be handled in the Linux services that Advantage Web provisions to its clients. There is nothing worse than being unable to solve technical problems.

Amazon AWS Linux instances use “burst cpu” when CPU demand is momentarily too high, by dipping into a free CPU credit available to you, thus stopping a blank web page or crash. The AWS EBS hard disk storage is rated as high-performance and reliability, so excessive use of disk swapping is not as chronic as it otherwise could be.

We are therefore able to “fine tune” a number of configurations to prevent services hogging the CPU and/or RAM and Disk. These are reasonable configurations which we follow. If there are still memory crashes, we have to investigate. It could be for example, a WordPress plugin doing something bad behind the scenes. It could be lack of prevention against basic hacking and port flooding. It could also be the hosting service is unfairly maxed out, needing an upgrade.

We typically edit the my.cnf database configuration file, and the www.conf PHP memory file to give a normal distribution of memory to competing services.

This does not exclude other problems such as a fault in the connection to the hosting service, their own hardware glitches or faults, or a typhoon in the Philippines that you did not know disconnected a database as used by the provider for your site.

Issues with Linux Out of Memory (OOM) Failures:

  • Linux systems run out of available memory, causing processes to be terminated unexpectedly.
  • This can lead to application crashes or degraded performance.
  • cPanel shared services are based on Linux. You have no access to the shared administration files or any say on the use of the hardware and how it is maintained.
  • VPS – Virtual Private Servers is the service Advantage Web offers, with full administrative access and protection from the above mentioned problems.
  • The VPS services on popular cPanel hosting sites are priced out of scope for a number of people, having their own “Eco-system” to deal with. Although technology changes, not all providers use the most current hardware and software. If it is available, paying for higher grade hardware and memory/resources is a significant cost – as you will notice when looking at various retail customer plans.
  • VPS services provided in Australia from dedicated developer teams, critical to big business, can be out of reach. Advantage Web fills in the gap by using the same profoundly robust systems for us regular folks and small business, sole traders and the like, accessing these same high-end systems. It is called “leveraging” and this is smart business practice.

Impact on Business:

  • Service disruptions and downtime can affect customer experience.
  • Data processes or websites may become unavailable.
  • Increased operational costs due to manual interventions.

Troubleshooting and Fixing OOM Failures:

  • Monitor memory usage metrics to identify trends.
  • Check logs (dmesg, /var/log/syslog) to see which processes are killed.
  • Ensure no single process consumes excessive memory.

Configuring PHP-FPM (www.conf) and MySQL (my.cnf) to Prevent OOM:

  • For PHP-FPM:
    • Set pm.max_children to limit the number of PHP processes based on available memory.
    • Use pm.start_servers, pm.min_spare_servers, and pm.max_spare_servers to control process spawning.
  • For MySQL:
    • Adjust memory-related settings like innodb_buffer_pool_size and key_buffer_size to fit server capacity.
    • Use max_connections to limit simultaneous connections.

Approach to Address the Problem:

  • Optimize resource limits and process configurations.
  • Implement proactive monitoring and alerts.

Automating Restart of Services on Memory Issues:

  • Set up scripts or systemd service restart directives.
  • Use monitoring tools to detect OOM events.
  • Configure automatic restarts when memory thresholds are exceeded.

advantageweb.au