Программа Nuxt.js в Использует все ресурсы в Linux
У меня есть сайт, созданный на nuxt.js, я использую ssh-скрипт для обновления сайта и pm2 в качестве диспетчера процессов. Все работает нормально, но когда у сайта относительно высокий трафик, он падает. Администрация сервера пояснила, что существующее приложение использует все ресурсы сервера, ОЗУ на сервере составляет около 36 ГБ. На момент запуска все приложение использует 3,4 ГБ ОЗУ. Я прочитал много ресурсов, но не смог найти правильный источник, может все это быть вызвано узлом-модулем? Любые подсказки мне помогут, заранее большое спасибо
//ecosystem.config.js
module.exports = {
apps: [{
name: 'NuxtAppName',
exec_mode: 'cluster',
instances: 'max', // Or a number of instances
script: './node_modules/nuxt/bin/nuxt.js',
args: 'start'
}]
}
//package.json
{
"name": "devcomn",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"@nuxtjs/axios": "^5.13.1",
"@nuxtjs/robots": "^2.5.0",
"@nuxtjs/sitemap": "^2.4.0",
"@nuxtjs/toast": "^3.3.1",
"axios": "^0.21.1",
"bootstrap": "^4.6.0",
"bootstrap-vue": "^2.21.2",
"core-js": "^3.9.1",
"js-cookie": "^2.2.1",
"nuxt": "^2.15.3",
"nuxt-facebook-pixel-module": "^1.5.0",
"nuxt-lazy-load": "^1.2.6",
"nuxt-moment": "^1.0.5",
"swiper": "^5.4.5",
"v-mask": "^2.2.4",
"vee-validate": "^3.4.11",
"vue-authenticate": "^1.5.0",
"vue-awesome-swiper": "^4.1.1",
"vue-axios": "^3.2.4",
"vue-google-oauth2": "^1.5.8",
"vue-lazy-hydration": "*",
"vue-select": "^3.11.2",
"vue-slider-component": "^3.2.13",
"vue-star-rating": "^1.7.0",
"vue2-dropzone": "^3.6.0",
"vue2-editor": "^2.10.2"
},
"devDependencies": {
"@nuxtjs/google-analytics": "^2.4.0",
"fibers": "^5.0.0",
"sass": "^1.32.11",
"sass-loader": "^10.1.1"
}
}
nuxt.config.js
const axios = require('axios')
export default {
// Global page headers: https://go.nuxtjs.dev/config-head
head: {
title: 'site',
htmlAttrs: {
lang: 'en'
},
meta: [
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
],
script: [
]
},
// Global CSS: https://go.nuxtjs.dev/config-css
css: [ '~/assets/css/transition.css', '~/assets/css/errors.css' ],
pageTransition: "fade",
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
plugins: [
{ src: '~/plugins/axios' },
{ src: '~/plugins/vue-fbauth.js', ssr: false },
{ src: '~/plugins/vue-google', ssr: false },
{ src: "~/plugins/star-rating", ssr: false },
{ src: "~/plugins/mask", ssr: false },
{ src: "~/plugins/rangeSlider", ssr: false },
{ src: "~/plugins/vueSelect", ssr: false },
{ src: "~/plugins/vuelidate", ssr: false },
],
// Auto import components: https://go.nuxtjs.dev/config-components
components: true,
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
buildModules: [
[ '@nuxtjs/google-analytics', {
id: ''
} ]
],
// Modules: https://go.nuxtjs.dev/config-modules
modules: [
// https://go.nuxtjs.dev/bootstrap
'bootstrap-vue/nuxt',
'@nuxtjs/axios',
'@nuxtjs/toast',
'@nuxtjs/auth-next',
[ 'nuxt-lazy-load', {
defaultImage: '/spin2.gif'
} ],
[ 'nuxt-facebook-pixel-module', {
/* module options */
track: 'PageView',
pixelId: '',
autoPageView: true,
disabled: false
} ],
'nuxt-moment',
'@nuxt/http',
'@nuxtjs/robots',
'@nuxtjs/sitemap'
],
moment: {
locales: ['ka', 'en']
},
toast: {
position: 'top-center',
},
robots: [
{
UserAgent: '*',
Disallow: ['/user', '/admin'],
},
],
axios: {
baseURL: 'https://api.site.com/', // Used as fallback if no runtime config is provided
},
sitemap:{
exclude:[
'/user',
'/admin',
'/admin/*',
'/user/*',
],
defaults: {
changefreq: 'daily',
priority: 1,
lastmod: new Date()
},
routes: async () => {
const { data } = await axios.get('https://api.site.com/api/book/all')
return data.map((product) => `https://site/product/${product.id}/${product.name}`)
}
},
loading: {
color: '#F48245',
height: '4px'
},
target: 'server',
// Build Configuration: https://go.nuxtjs.dev/config-build
build: {},
router: { middleware: [ 'checkUserAuth' ] },
};