Skip to main content

Database Optimization

Optimizing your database is one of the most effective ways to improve overall Frappe performance. Since Frappe relies on MariaDB/MySQL, standard database tuning practices apply directly. Proper hardware sizing, database configuration, and continuous monitoring help reduce query latency and improve application responsiveness.

Best Practice

Run the database server separately from the application server whenever possible. This allows both servers to be tuned independently and prevents application workload spikes from affecting database performance.

Recommended Server Architecture

Separating the database and application servers provides more predictable performance and simplifies hardware scaling.

  • Application servers often experience fluctuating CPU and memory usage.
  • Database servers perform best with consistent access to RAM and storage.
  • Each server can be optimized independently for its workload.

CPU Recommendations

Begin with at least 2 vCPUs. CPU determines how many database operations can execute simultaneously.

Monitor CPU utilization regularly. If average usage stays above 50–60% for extended periods, consider upgrading the available CPU resources.

Memory (RAM)

MariaDB uses RAM for its InnoDB Buffer Pool, allowing frequently accessed data to remain in memory instead of being read from disk.

  • Start with at least 8 GB RAM.
  • A properly tuned server should serve most reads directly from memory.
  • Increase RAM as your database size and active working set grow.

Important

Avoid relying on swap memory for database performance. Databases already manage memory efficiently. Keep only a small swap partition for emergency situations and reduce system swappiness.

Disk Storage and IOPS

Fast storage significantly impacts database performance.

  • Use SSD storage whenever possible.
  • Provision approximately three times your current database size.
  • Start with at least 50 GB of storage.
  • Target roughly 2000–3000 IOPS for production workloads.

Monitoring disk usage and I/O activity helps determine when additional storage performance is required.

Scaling Database Resources

Scale vertically before considering database clustering or sharding.

For most deployments, increasing CPU and RAM continues to improve performance until approximately 64 vCPUs and 128 GB RAM.

When read traffic becomes very high, configure a database replica so heavy read operations can be routed away from the primary database server.

Database Configuration

MariaDB includes numerous configuration options, but several settings have the greatest impact on Frappe performance.

InnoDB Buffer Pool

The innodb-buffer-pool-size setting controls how much data remains cached in memory.

As a general guideline:

  • Allocate roughly 60% of available RAM to the Buffer Pool.
  • The Buffer Pool should be large enough to contain your frequently accessed data.
  • Monitor buffer pool utilization before increasing its size.

Buffer Pool Monitoring

Useful metrics include:

  • Buffer Pool Hit Ratio (ideally above 99%)
  • Buffer Pool Utilization (typically between 95–100%)

You can review these statistics using:

SHOW ENGINE INNODB STATUS;

Important MariaDB Settings

Some commonly recommended production settings include:

  • innodb-flush-method = O_DIRECT
  • innodb-flush-log-at-trx-commit = 1
  • innodb-file-per-table = 1
  • slow-query-log = 1
  • query-cache-type = 0
  • query-cache-size = 0

These settings improve durability, reduce unnecessary disk activity, and make slow query analysis much easier.

Monitoring Database Performance

Continuous monitoring is essential for identifying bottlenecks before they affect users.

Recommended monitoring tools include:

  • Prometheus
  • Grafana
  • Node Exporter
  • MySQLD Exporter
  • Percona Monitoring and Management (PMM)
  • MariaDB Slow Query Log

Key Metrics To Track

Regularly monitor the following metrics:

  • CPU utilization
  • Memory usage
  • Disk I/O
  • InnoDB row reads
  • Buffer Pool miss ratio
  • Row lock wait load
  • Buffer Pool LRU churn

Unexpected increases in these metrics often indicate inefficient queries, insufficient memory, or increased application load.

Additional Resources

For deeper database tuning guidance, refer to the official documentation for MariaDB, MySQL, and Percona performance optimization.

Performance Tip

Database optimization is an ongoing process rather than a one-time task. Regular monitoring, reviewing slow queries, tuning the InnoDB Buffer Pool, and upgrading hardware based on observed workload patterns will deliver the best long-term performance for Frappe applications.

Rating: 0 / 5 (0 votes)