Limiting the number of unicorns, memory usage and swapping

It certainly looks like your site would be quicker if you had more RAM. But if the response time isn’t a problem, there’s no problem. Just look at your personal cost/benefit equation.

You might be interested in reading MKJ’s Opinionated Discourse Deployment Configuration. There are a couple of system-level kernel tweaks which are a good idea. I don’t know whether or not they will make a difference.

I don’t know, but I think each unicorn can deal with a request. So if you have just one unicorn, and enough traffic for a second request to come in before the first is done, that second request will have to wait. You can see from my htop output that one unicorn has run up 10x the CPU time of the other. I’d take that to mean that my forum is 90% of the time in need of only one unicorn, and 10% of the time that second unicorn is helpful. I don’t feel any need to add a third, and it mightn’t be a big deal to my forum members if I went down to one. But I see no reason to: it may use memory, but if it’s idle then it will get swapped out. No big deal: let the virtual memory system deal with it.

Edit: I’ve never tweaked swappiness. Seems to be at 60. More aggressive swapping might be useful if it frees more RAM for I/O buffers. I don’t know.

2 Likes