كيفية حل خطأ HTTP 502؟

At this scale I recommend dedicated PG resources, any reason you are not running your database on a dedicated instance or managed PG?