Nuxt 2.17 server getting slow and stop working

I have a bunch of Nuxt 2.17 + Vuetify 2 apps that all share same core.
all work fine except one of them.
The one that has issue in a few days (2~3 days) get slower and slower until it wont handle ssr requests anymore (get 429 error although that same request when is sent on client-side is resolve 200). Specially one of the domains that is set on it and has more traffic than others. So I have to restart pm2 to get it back to normal. sometime the restart won’t solve the issue and have to remove .nuxt file and rebuild it.

  • I had keep-alive on this server’s app and removed it but didn’t solve the issue
  • I have no custom cache on it (if there is, it’s nuxt/webpack ddefaults)
  • This particular server handles users so there is much more usage and also there are a lot of reverse proxy on it (it is a client side of my SaaS app so each domain gets and show that user’s data)

the things that i did in my app and is in the core of all others too, are:

  • I get init data (that domains specific data) in nuxtServerInit() and set it on a vuex state
  • I have a global mixin that has a moment.js import in it.
  • I have i18n with 11 locales (lazy loaded)
  • I created a repository design (injected a plugin into nuxt that read my different API calls):
// repoplugin.js that is added to nuxt.config.js
import createRepository from '@/repos/repository.js'
export default (ctx, inject) => {
  inject('repository', createRepository(ctx.$axios,ctx.i18n,ctx.store))
}


// repository.js
import InitRepository from '@/repos/InitRepository.js'
export default ($axios,$i18n,store) => ({
    init: InitRepository($axios,$i18n)
    ...
)}


// InitRepository.js
export default ($axios) => ({
    init(depth=1, {errorAlert=false, successAlert=false,...options}={}){
        return $axios.get(`settings/init`,{errorAlert,successAlert,...options})
    },
})

  • also have resource system that import it in my pages/components when i need
// UserModel.js
export function UserInfoResource(data){
    return {
        id: data?.id,
        firstName: data?.firstName,
        lastName: data?.lastName,
        email: data?.email,
        phone: data?.phone,
        gender: data?.gender
    }
}

// usage :
import {UserInfoResource} from '@/models/UserModel.js'
export default{
  data(){
    user: UserInfoResource()
  },
  methods:{
    async getUser(){
      let res = await this.$repository.user.show()
      this.user = UserInfoResource(res.data)
    }
  }
}

these are pretty much what i do in my apps.
as I said , the only difference is the number of users and reverse proxies in the problematic server.

my cms app is much more heavier code and functionality wise, but never had an issue (doesn’t have reverse proxy on it though) , also some other servers has reverse proxy but the number on domains and the users that land on them are low.

So that is my Issue. and one last thing, can state management (vuex) cause server issues like high memory usage??

Also did a simple memory heap test on my local computer and couldn’t see an in memory.

export default () => {
    setInterval(() => {
        const memoryUsage = process.memoryUsage();
        console.log(`
            RSS: ${Math.round(memoryUsage.rss / 1024 / 1024)} MB,
            Heap Total: ${Math.round(memoryUsage.heapTotal / 1024 / 1024)} MB,
            Heap Used: ${Math.round(memoryUsage.heapUsed / 1024 / 1024)} MB,
            External: ${Math.round(memoryUsage.external / 1024 / 1024)} MB,
            Array Buffers: ${Math.round(memoryUsage.arrayBuffers / 1024 / 1024)} MB
        `);
    }, 60000); // Log every minute
};