I’ve got a 2-container install on a DO 8GB droplet that is behaving very strangely.
There is a postmaster (EDIT: now there are two of them) processing eating 100% CPU.
Sidekiq is running, but the Dashboard complains that it’s not checking for updates.
There are some logs like
PG::ConnectionBad (FATAL: remaining connection slots are reserved for non-replication superuser connections ) /var/www/discourse/vendor/bundle/ruby/2.4.0/gems/pg-0.21.0/lib/pg.rb:56:in `initialize'
and
Job exception: FATAL: remaining connection slots are reserved for non-replication superuser connections
The data container has:
db_shared_buffers: "2GB"
db_work_mem: "40MB"
There are 4 unicorn workers in the web container (same as # processors).
The postgresql connection limit needs to be increased. That will cause the database as a whole to use more memory, but based on the free output you’ve got plenty that could be used if required. I’d double the current value, and review errors and resource consumption.
I did that, but I’m still getting a 502 error on the admin dashboard.
The other issue is that this site is using cloudflare with no caching (I’m told). I have included the cloudflare template, but I still suspect something is wrong with cloudflare.
It’s the max_connections parameter in postgresql.conf. I don’t see a tunable for that in discourse_docker, so I suspect you’ll need to play games with a pups exec stanza to make the edit.
As for Cloudflare, all the cloudflare template does it make it so that IP addresses get fixed after going through Cloudflare proxying. It doesn’t do anything to make Cloudflare cache. You might want to keep that in a separate topic, rather than mix them together in here.
Not one for playing games when they’re not necessary, I went into the data container, edited postgresql.conf by hand, doubled max_connections (from 100 to 200) and, LO! it seems that all is well.
I don’t understand just why I’ve not encountered this before or why this is the solution here. The database doesn’t seem that big and the traffic doesn’t seem that high.
Edit: I have played the games and won!
If anyone else cares. . . stick this in data.yml in hooks in the after_postgres section. I put it after the -exec section.
# double max_connections to 200
- replace:
filename: "/etc/postgresql/9.5/main/postgresql.conf"
from: /#?max_connections *=.*/
to: "max_connections = 200"
@pfaffman 이 방법으로 포스트마스터가 CPU 사용률을 과도하게 높이는 문제를 해결하셨나요?
postgresql.conf(/var/discourse/shared/standalone/postgres_data/postgresql.conf)에서 max connections를 직접 수정하고 ./launcher rebuild app을 실행해 보았지만, 달라진 점을 느끼지 못했습니다.
Postgres에 더 많은 메모리를 할당해보고, 다시 줄여보기도 했습니다. 스왑을 추가한 것이 도움이 된 것 같습니다(그래서 Postgres에 할당하는 메모리를 줄여본 것입니다). 도움이 되었을 수 있는 또 다른 작업은 데이터베이스를 백업하고 복원한 것입니다. 아니면 아무 효과가 없었을 수도 있고요.
2.5.0.beta5 업데이트를 설치한 후에도 나에게서 같은 문제가 발생하기 시작했습니다. 하나씩 더 많은 postmaster 프로세스가 생성되며, 각 프로세스가 가능한 한 많은 CPU를 사용하다가 완료되기까지 몇 분씩 걸리는 경우가 있습니다. 이로 인해 서버의 AWS 크레딧이 서서히 소진되고, 전체 포럼이 느려지거나 심지어 사용할 수 없게 됩니다.
max_connections를 늘리거나 앱을 재빌드해도 효과가 없었습니다.
2.5.0beta5로 업데이트하기 전까지는 이런 현상을 본 적이 없습니다. 어디서부터 확인해야 할지 힌트를 주실 수 있나요?