Question

Do I really need a bigger dropplet to fix these memory issues?

I’m an artist and have a small website with a wordpress installation with a few static pages, and for a long time I’ve had issues with the website crashing from running out of memory. I’ve run mySQLtuner loads of times and eventually exhausted all the setting options it told me, but my website still crashes. Sometimes it goes a few weeks without crashing, others it crashes most days, like this week.

I’m on the smallest droplet with 1GB memory, and a lot of articles I see on troubleshooting say to just upgrade the server size. I don’t much fancy having to pay double the hosting costs without being sure it’s necessary. So I wanted to ask from people who know better. Is 1GB really not enough for a dinky website like mine? There’s like nothing on it, and I have Redis object cashing enabled.

Are there things I could try to possibly fix this? I’ve been holding off on asking for help for so long, but it’s gotten to be such a pain. :\


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
October 18, 2023

Heya,

It can be frustrating when your website keeps crashing due to memory issues, but there are several potential reasons for this, and it’s worth exploring some solutions before jumping to a more expensive hosting plan. While 1GB of memory is on the lower side, it should still be sufficient for a small WordPress website if it’s properly optimized.

Here are some steps to consider:

  1. Optimize Your WordPress Website:
  • Caching: You mentioned that you have Redis object caching enabled, which is good. Consider using a full-page caching plugin like W3 Total Cache or WP Super Cache to reduce server load.

  • Minimize Plugins: Evaluate the plugins you have installed and deactivate or remove any unnecessary ones. Some plugins can be resource-intensive.

  1. Check Resource Usage:
  • Analyze your website’s resource usage. You can use tools like New Relic, Query Monitor, or P3 Profiler to identify resource-hungry plugins or themes.

  • Monitor server resource usage with tools like top, htop, or the server’s monitoring dashboard to see if a specific process is causing the high memory usage.

  1. Review Your Theme:
  • Some themes can be resource-intensive. Switch to a lightweight theme like Astra or GeneratePress if your current theme is heavy.
  1. Optimize Your Database:
  • Regularly optimize your database tables to free up space. You can use plugins like WP-Optimize or WP-Sweep.
  1. Use Content Delivery Network (CDN):
  • A CDN can offload some of the server’s work and speed up your site by caching static content and serving it from a network of global servers.
  1. Consider Caching Solutions:
  • Use server-level caching mechanisms like Varnish, if available on your hosting.
  1. Check for Spam and Malware:
  • Ensure your website is not compromised. Malware or spam attacks can consume server resources.
  1. Upgrade PHP Version:
  • Ensure that you are running the latest supported version of PHP. Newer versions are usually more efficient.
  1. Optimize Images:
  • Compress and optimize images to reduce the size of your web pages.
  1. Consider Content Delivery Optimization:
  • Use lazy loading for images and load content asynchronously to improve page load times.
  1. Review Server Configuration:
  • Check if there are any server configurations that could be optimized for better performance.
  1. Server Log Analysis:
  • Review server logs for any errors or warnings that might indicate issues with your server configuration or specific plugins.

If you’ve tried all of these and still experience memory issues, it might be worth considering upgrading your hosting plan.

Remember to take regular backups of your site before making any significant changes, and implement changes gradually, monitoring the performance impact as you go. This way, you can identify which optimizations are most effective for your specific case.

Hope that this helps!

KFSys
Site Moderator
Site Moderator badge
October 17, 2023

Heya,

Before going for an update, you might want to try and optimize both your Droplet and your Website. Here are some general tips to do so:

Let’s start with Server Optimization.

When looking at Server/Droplet Optimization, there are a few necessary services/packages that are universal.

  • The first one would be Server-side caching. Server cache is an umbrella term covering a number of different types of caching. This includes Content Delivery Network (CDN) caching, object caching, and opcode caching. Depending on what you want to achieve you might need one or the other. Usually, though, you can have all 3 types of caching as it shouldn’t interfere with your Website/App. I won’t go into more details about what each caching does as this post will become 3 pages long. There are multiple documents providing services/packages for each of the server-type caching.

  • Next would be using PHP-FPM (if your Website is using PHP of course). PHP-FPM is an efficient method on how to minimize the memory consumption and rise the performance for the Websites with heavy traffic. It is significantly faster than traditional CGI-based methods in multi-user PHP environments.

  • Another solution would be Database Caching. A database cache supplements your primary database by removing unnecessary pressure on it, typically in the form of frequently accessed read data. The cache itself can live in a number of areas including your database, application or as a standalone layer. Usually, for this kind of caching is being used Redis.

  • Apache NPM modules. If you are using Apache, you are using one of three NPM modules. Most certainly if you haven’t configured anything on it and have used the default configuration, you are using NPM_Prefrok which is the most outdated one and thus the slower. I’ll recommend using one of the other two - NPM_Worker and NPM_Event depending on your situation. Again, I would urge you to read more about these 3 and what is applied in which case.

  • Apache Workers. Basically, the Apache workers are equivalent to a room full of seats. These seats are the projection to your website. When someone opens your website, it’s like one person going to this room and sitting on one of the chairs. When the limit is reached, in order for a person to load your website, another one needs to close it. So basically, I’ll suggest increasing that value as well.

Those were the basic optimizations on a server level, let’s start with your Website/App

Since you are using WordPress, there will be plugins/addons. These addons can be very powerful if used correctly. The most helpful plugins are:

  • Caching Plugins
  • Image Optimization Plugins
  • Plugins that reduce redirections/requests
  • Plugins that reduce the size of JS and CSS files.
  • More often than not, there are a lot of JS and CSS files that are not being used, removing those should work as well

Usually, Websites/Apps are slow because of a couple of reasons which range from too many requests or big images to a bunch of unnecessarily big JS or CSS files. Optimizing these whether you are using a Plugin or doing it manually is enough.

Hope this helps!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel