Discourse site with very large database gives error 502 frequently

  1. Have you attempted to back up and re-import the database after migration? This can really help.

  2. Or you try this to optimize the database:

     cd /var/docker
     ./launcher enter app
     sudo -u postgres psql discourse
     VACUUM ANALYZE;
     \q
    
  3. Try to comment out the line with templates/web.ratelimited.template.yml in app.yml. (Must re-create the app)

  4. You can try to set db_shared_buffers to 2GB. Possibly 3GB depending on the other services you are running. (Must re-create the app)

  5. If you have low CPU load, you can carefully increase UNICORN_WORKERS. (Must re-create the app)

  6. If nothing helps, get more RAM and more cores. I’d say 8GB, best if you could load the entire database into the RAM. And 4 physical cores with high single thread performance.