使用MailjetApi发送5K电子邮件时出错。
我的编码:
function arraySend(array, locals) {
var mailjetConnect = mailjet.connect(locals.blocks.mailjetparam.username, locals.blocks.mailjetparam.password),
chunkedArrayMessages = _.chunk(array, 50),
delay = ms => new Promise(resolve => setTimeout(resolve, ms)),
promises;
if (process.env.NODE_ENV.trim() === 'dev') {
return Promise.resolve();
} else {
promises = chunkedArrayMessages.map((messages) => {
return Promise.all([
delay(1000),
mailjetConnect.post('send', { version: 'v3.1' }).request({ Messages: messages }).then(() => {
return Promise.resolve();
}).catch(() => {
return Promise.resolve();
})
]);
});
return Promise.all(promises).then(function() {
return Promise.resolve();
}).catch(function(err) {
return Promise.reject(err);
});
}
}
字符串
错误:
<--- Last few GCs --->
[30337:0x51226d0] 59607 ms: Mark-sweep (reduce) 4085.3 (4103.8) -> 4085.1 (4107.6) MB, 71.7 / 0.1 ms (+ 79.5 ms in 40 steps since start of marking, biggest step 78.8 ms, walltime since start of marking 255 ms) (average mu = 0.852, current mu = 0.779) [30337:0x51226d0] 59810 ms: Mark-sweep (reduce) 4087.0 (4108.0) -> 4086.9 (4109.0) MB, 119.3 / 0.1 ms (average mu = 0.781, current mu = 0.411) allocation failure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memor
型
我的NodeJS应用程序使用PM2和process.json
启动。
启动NodeJS应用的命令:sudo pm2 start process.json --node-args="--max-old-space-size=4096"
我的PM2的process.json:
{apps:[{name:"*****.fr:3006",cwd: "****/mywebsite/cms",script: "./index.js",watch:false, env: {"NODE_ENV": "prod"}}]}
型
Package.json:
"start": "set NODE_ENV=prod & node index.js",
型
我的服务器:
的数据
2条答案
按热度按时间v09wglhw1#
您可以将批处理大小从5 K减少到1 K,并在Apache Kafka / RabbitMQ中对批处理进行排队。
kokeuurv2#
由于Mailjet的限制,您将无法绕过异步函数。试试这个方法。你可能需要调整一些部分。
字符串