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?