The discussion revolves around resolving HTTP 502 errors on a Discourse server with 8GB of memory and a quad-core processor, handling 200-300 concurrent users. xuchao_007 initially reported high memory and CPU usage during peak times.
To resolve the issue, pfaffman suggested ensuring the entire database fits in cache, with at least half of it covered if the database is very large, as noted by codinghorror. xuchao_007 was advised to modify the app.yml file for memory tweaks, and they attempted to set ‘db_shared_buffers’ to 4096MB, which reduced the frequency of errors.
Further investigation revealed a 9.72GB database size and over 270,000 requests from 789 IPs in 2 hours when the error occurred. sam recommended dedicated PostgreSQL resources, but codinghorror mentioned that a similar instance handles a database of this size without dedicated PostgreSQL. sam suggested implementing a CDN to break down dynamic vs static requests and to potentially handle image serving.
I set up discourse on a instance that contains 8GB of memory and a quad-core processor on Microsoft Azure, and I run into HTTP 502 problems these days. Especially when there are about 200 to 300 registered users visiting at the same time, the server goes wrong with HTTP 502 error. The server logs shows memory usage and CPU usage are high (above 90%) during peak times.I guess that is because each connection takes up too much resource, but I don’t know how to optimize.
So I wonder what I can do to resolve this, except upgrading hardware configurations. Thank you for any advice!
@pfaffman Thanks for your advice.
I have set ‘db_shared_buffers’ to 4096MB in app.yml and rebuild. The problem seems to occur less frequently after making that change, but still remains unsolved.
If my calculations are correct, the size of database should be 9.72GB.
When the last time HTTP 502 error occured, the server received about more than 270,000 requests from 789 ips in 2 hours.
I got these two numbers using the command below:
Was thinking about the load here vs the DB size 135k reqs an hour is probably a lot especially if this is peaking in some times at say 1000/sec due to the way traffic works.
Though step 0 here @xuchao_007, get a CDN in place so you can get a good breakdown of dynamic vs static requests. Unclear how much of this traffic is serving images vs the server doing work.