nodejs生産環境の配置と最適化
916 ワード
1.余分なカバンを取り除く
npm prune--production
2.コードの最適化を使う
a.grunt-contrib-glify、コードを簡潔にする
b.全ソロを除く.*
c.grunt-contrib-jshintを使ってコードを検出する
3.できるだけstrict modeを使う
ファイルでは'use strict'またはコマンドnode--use_を使用します.ストリップ
4.メモリ最適化、ゴミ回収v 8-options
64ビットV 8は1.5 Gメモリの上限で、32ビット0.7Gです.下記のパラメータで修正できます.
--max_new_spacesize(max size of the new generation(in kBytes)
type:int default:0
--max_old_spacesize(max size of the old generation(in Mbytes)
type:int default:0
--max_executable_size(max size of executable memory(in Mbytes)
type:int default:0
--gc_global(always perform global GCs)
type:book default:false
--gc_interval(garbage collect afterallocations)
type:int default:-1
npm prune--production
2.コードの最適化を使う
a.grunt-contrib-glify、コードを簡潔にする
b.全ソロを除く.*
c.grunt-contrib-jshintを使ってコードを検出する
3.できるだけstrict modeを使う
ファイルでは'use strict'またはコマンドnode--use_を使用します.ストリップ
4.メモリ最適化、ゴミ回収v 8-options
64ビットV 8は1.5 Gメモリの上限で、32ビット0.7Gです.下記のパラメータで修正できます.
--max_new_spacesize(max size of the new generation(in kBytes)
type:int default:0
--max_old_spacesize(max size of the old generation(in Mbytes)
type:int default:0
--max_executable_size(max size of executable memory(in Mbytes)
type:int default:0
--gc_global(always perform global GCs)
type:book default:false
--gc_interval(garbage collect after
type:int default:-1
node --use_strict --max_old_space_size=2000 --max_executable_size=2000 --gc_global --gc_interval=200 app.js