# Discourse site with very large database gives error 502 frequently

**URL:** <https://meta.discourse.org/t/discourse-site-with-very-large-database-gives-error-502-frequently/57598>\
**Category:** Product Support\
**Created:** [18 Febbraio 2017, 4:13pm UTC](https://meta.discourse.org/t/discourse-site-with-very-large-database-gives-error-502-frequently/57598 "2017-02-18T16:13:07Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Lutz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lutz/32/65103_2.png) [@Lutz](https://meta.discourse.org/u/Lutz)\
**Post date:** [18 Febbraio 2017, 5:22pm UTC](https://meta.discourse.org/t/discourse-site-with-very-large-database-gives-error-502-frequently/57598/10 "2017-02-18T17:22:49Z")

</div>

> [@veer](#):
>
> What should I do ?

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:

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.

---

_[View the full topic](https://meta.discourse.org/t/discourse-site-with-very-large-database-gives-error-502-frequently/57598)._
