I have installed discourse and noticed 1 second page loads in some cases. I enabled logging of queries on postgresql and noticed all queries executed in less than 10 milliseconds. However, looking at the /var/www/discourse/log/production.log file (I used docker exec to view this log). I noticed a couple logs that looked something like this:
Completed 200 OK in 724ms (Views: 20.1ms | ActiveRecord: 439.7ms)
Can anybody with knowledge advice on how the ORM framework can carry such overhead. Could i possibly be missing a configuration setting?
That smells… swappy. AR does a lot of memory work to convert data between formats, and if you’re a bit tight on memory, it could end up touching lots of pages that need to be swapped in.
It is running on a 16 GB instance and has over 6 GB of free ram available at the moment. Also the instance is using 2 GB RAM at the moment inferred from docker stats.
I am using the official docker image, but i an running both PostgreSQL and Redis on independent servers. The discourse container is running on Bare metal, HDD, Intel® Xeon® CPU E3-1230 v6 @ 3.50GHz, X86_64 architecture. The PostgreSQL and Redis instances are however running on SSD servers.
Thanks for the latency hint. I all along thought the PostgreSQL server was in the same data center. I just noticed both the Redis server and PostgreSQL server are both 13.6 ms ping time away from the discourse containers. That is unacceptable. Will look into improving this. I had assumed it was around 0.1 ms which is typical when they are in the same data center.