Periodic "Socket hang up" errors in production with Next.js and Strapi on Heroku

System Information
  • Strapi Version: 4.5.1
  • Database: Postgres
  • Node Version: 16
  • NPM Version: 6

I’m experiencing an issue with my Next.js application that uses Strapi as a headless CMS, both hosted on Heroku. In my application, I fetch data from Strapi using multiple (6) concurrent requests via Promise.all() in the getStaticProps function. Using the revalidate property the specific site should only be generated every 500 seconds. The setup works fine in my development environment and when running locally, but when deployed to production, the Strapi server occasionally fails, causing the whole page to display a 404 error on the frontend. When the issue occurs, we receive a “Socket hang up” error.

Our production environment serves around 2,000 users per day, and we’re using a basic Heroku dyno with 512 MB RAM and 1x CPU share. I saw that the minimum requirements for us to run Strapi aren’t met by that dyno (as we should use at least 2GB) but I just want to make sure that the concurrent requests are the problem before I upgrade the server.
We’ve been using Strapi for over a year as our headless CMS (with that server configuration) and it all worked fine. So I just want to make sure that the actual problem are the 6 requests fired at the same time before I redeploy to production.
Any advice or insights would be greatly appreciated.