If you rely on a Ghost installation on DigitalOcean, it is important to manage Memory usage and configure mySQL.

Ghost, as a powerful blogging platform built on Node.js, is designed to offer a sleek and efficient user experience, but it can sometimes become resource-intensive, especially on smaller or more limited server configurations. This high memory usage can lead to several issues, including slower response times, server crashes, and even unexpected downtimes, all of which can negatively impact the user experience and accessibility of the blog.

Several factors can contribute to high memory usage in this setup. These include increased traffic, inefficient code, insufficient server resources, and the use of plugins or themes that demand a lot of memory. Additionally, improper configuration of the Ghost instance or the underlying server (such as not setting appropriate limits for worker processes) can further exacerbate the problem.

For users hosting their blogs on DigitalOcean, a platform known for its simplicity and scalability, the impact of high memory usage can be particularly frustrating. It often requires a balance between managing costs and ensuring performance, prompting users to seek optimization strategies that can efficiently handle the demands of their sites without upgrading to a more expensive Droplet.

Addressing these challenges involves a combination of monitoring tools, proper configuration, and sometimes scaling resources. Whether it's optimizing the application's configuration, employing caching strategies, or adjusting the server setup, each approach plays a crucial role in ensuring that the Ghost blog runs smoothly while providing a reliable and fast experience for all visitors.

red and black heart illustration
Photo by Martin Sanchez / Unsplash

The my.cnf file in Ubuntu is the primary configuration file for MySQL server and other related MySQL-based programs like Percona Server and MariaDB. This file is critical for adjusting the behavior of the database server, including settings for performance, security, and basic functionality. Here's a detailed look at the technical aspects of my.cnf:


The my.cnf file can be located in several directories on Ubuntu, depending on the MySQL version and the specific installation details. Common locations include:

  • /etc/mysql/my.cnf: The main directory for MySQL configuration files.
  • /etc/my.cnf: A less common location but possible depending on custom installations.
  • ~/.my.cnf: User-specific configuration options can be set in this file in the user's home directory.


The my.cnf file is structured into sections, each starting with a header in square brackets. Here are some common sections:

  • [mysqld]: Settings specifically for the MySQL server daemon.
  • [client]: Configuration that applies to all MySQL client programs.
  • [mysqld_safe]: Options for the mysqld_safe script that helps in starting the server safely.
  • [mysql]: Default options for the mysql command-line client.

Key Configuration Options

  • port = 3306: Specifies the port MySQL should listen on; 3306 is the default MySQL port.
  • bind-address = Controls the IP address that MySQL server listens on. It is typically set to to restrict connections to the local machine only.
  • datadir = /var/lib/mysql: Specifies the directory that stores the database files.
  • socket = /var/run/mysqld/mysqld.sock: Location of the socket file used for local connections.
  • max_connections = 151: Sets the maximum number of simultaneous connections MySQL can handle.
  • innodb_buffer_pool_size = 256M: Sets the size of the buffer pool, the memory area where InnoDB caches table and index data.
photo of swirling fireworks
Photo by Guillaume de Germain / Unsplash

Best Practices

  • Security: Ensure settings like bind-address are configured to limit unwanted remote access.
  • Performance Tuning: Adjust performance-related settings such as innodb_buffer_pool_size according to your server's RAM and your application's requirements.
  • Backup: Always back up my.cnf before making changes, and document any changes made for future reference.
  • Version Control: It can be useful to keep my.cnf under version control to track changes and facilitate migrations or troubleshooting.

Modifying my.cnf

To modify my.cnf, it's recommended to use a text editor with root privileges:

sudo nano /etc/mysql/my.cnf

Add the changes below to the my.cnf


# Disable performance schema to hugely reduce RAM usage
performance_schema = OFF

# I'm not sure if these two commands make any difference, but they don't seem to hurt


# Settings to reduce RAM

# Settings to reduce RAM: per thread or per operation settings

# Settings to reduce RAM: settings that relate to the binary log (if enabled)

After making changes, restart the MySQL service to apply them:

sudo systemctl restart mysql

Looking at the metrics on DigitalOcean shows a significant decrease of memory usage, approximately 20%.

Share this post