Forum Unusable due to "500 Internal Server Error"


#1

I’m using a 2GB Digital Ocean Droplet and I keep getting 500 errors when users are trying to post new comments.

I checked the server logs and I see them full of these 2 lines:

44:M 22 Feb 12:10:04.079 * 1 changes in 900 seconds. Saving…
44:M 22 Feb 12:10:04.079 # Can’t save in background: fork: Cannot allocate memory

Also, when I ssh into my droplet, I see that memory consumption is at 82%.

I tried updating everything to latest, resetting the machine, but nothing helps on the long run. It works ok for a bit an then starts throwing the errors again.


(Jay Pfaffman) #2

Do you have swap configured? How big is your database?


#3

@pfaffman No swap configured. I remember that when I deployed the forum 2 years ago it was required only for 1GB instances. Should I have swap?

The forum has 6.9k posts and I have 18.1 GB free on the server. Hope this info is enough, Otherwise, how can I check the db size?


(Jay Pfaffman) #4

The memory requirements have increased in the past couple years.

I’d see if swap space would solve your problem:


#5

Ok, I’ve made a swap now. Will update this after seeing how it goes. Thanks for the suggestion!


(Jeff Atwood) #6

Even 1GB works fine, provided you have 2GB of swap, over a series of years running Discourse.

There are sometimes brief periods (usually during upgrades; it is strange to hear about this during regular use) where memory needs to be a bit larger.

It is definitely interesting to hear that no swap at all is affecting 2GB RAM instances cc @sam


#7

@pfaffman The swap file seems to have fixed the issue so far. Thanks again!
@codinghorror Let me know if you would like me to provide any other details that could be helpful in case you would like to investigate the possible cause. And thanks all for this great platform!

Btw, this is what I get now when running “free -h”

The swap used memory has been increasing in size since yesterday. Maybe there is some memory leak?


(Jeff Atwood) #8

Is your site very busy? What does the /about page show for stats? It’s possible your site is just very popular and thus needs more resources.


(Iceman) #9

Hi,

Sorry to bring this up from Februrary but whanted to ask if it’s normal to have intermittent Error 500 with ~80% memory usage (like the OP).

The site is under heavy usage, but just wanted to know if there is some kind of “estimations” for a correlation Users/VolumeOfTraffic - Memory.

I saw that a “Swap” was recommended, pardon my ignorance, but how do you achieve that, it’s recommended? Or is like removing the incorporated Rate Limiter (which was not recommended by Sam)

I’m running the latest version of Discourse.


(Jeff Atwood) #10

If you search the #howto category here there is a topic about adding swap. Running without swap is definitely not recommened, unless you have well over 2GB of RAM on your server already allocated to Discourse.


(Jay Pfaffman) #11

That doesn’t mean anything. How many page views per day/week/month?

You need enough RAM for your database to fit in memory. How big is your database, or how many posts are there?

How much RAM do you have? How fast is the CPU? Where are you hosted?