Fixing Production Request Timeout & Performance Enhancement in Frappe / ERPNext

A collection of common solutions for fixing Production Request Timeout in Frappe and improving system performance by tuning key services such as Gunicorn, MariaDB, Redis and more resources you will find at the end of this topic .


1. Check Background Workers and Scheduler

Use bench doctor to verify that workers and scheduler are running properly:

bench doctor

If workers or the scheduler are down, timeout issues and stuck jobs may occur.


2. Increase HTTP Timeout

Increase the HTTP timeout for long-running requests:

bench config http_timeout 600   # Timeout in seconds

3. Apply Config Changes to Supervisor and Nginx

After updating the timeout, regenerate supervisor and nginx configs:

bench setup supervisor
bench setup nginx

4. Restart Services (as root user)

Restart services to apply the changes:

sudo supervisorctl reload
sudo service nginx reload

5. Increase Gunicorn Workers

Increase Gunicorn worker count to improve request handling under load.

Edit common_site_config.json:

"gunicorn_workers": 5,

The recommended formula for number of workers is:

workers = 2 * CPU cores + 1

Then run:

bench setup supervisor
sudo supervisorctl reread
sudo supervisorctl update
bench restart

6. Tune MariaDB for Better Performance

Step 1: Edit MariaDB Configuration

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Step 2: Under [mysqld], add or update the following:

innodb_buffer_pool_size = 8G

Adjust the value based on your server’s RAM. For example:

  • 2 GB RAM: 512M – 1G
  • 4 GB RAM: 1G – 2G
  • 8 GB RAM: 4G – 6G

Step 3: Restart MariaDB

sudo systemctl restart mariadb

Step 4: Verify the Buffer Pool Size

mysql -u root -p -e "SHOW VARIABLES LIKE 'innodb_buffer_pool_size';"

Note: Value will be shown in bytes (e.g., 1073741824 = 1G)


7. Increase Redis RAM Usage

Step 1: Edit Redis Configuration

sudo nano /etc/redis/redis.conf

Step 2: Find and set maxmemory:

maxmemory 1gb
maxmemory-policy allkeys-lru

Replace 1gb with the amount of RAM you want Redis to use (e.g., 512mb, 2gb).

Step 3: Restart Redis

sudo systemctl restart redis

Step 4: Verify Redis Memory Settings

redis-cli info memory

Look for the following lines:

  • maxmemory
  • used_memory
  • maxmemory_policy

Resources For More Information:

  1. Database Optimization - Hardware and Configuration | Frappe Documentation
  2. Optimizing ERPNext Performance: Tips for Faster and Smoother Operations
  3. ERPNext Performance Tuning
  4. Performance Optimization Tips for ERPNext in Manufacturing Environments
  5. Slow Query Log Overview
  6. how to setup the slow query log
  7. Check MySQL (MariaDB) Configuration
  8. ERPNext running slow

If you any useful tips or another resources, feel free to share :pray:

3 Likes