Przeglądaj źródła

Mondify connection pool size from Express (#8353)

JaeHyeok Kim 2 lat temu
rodzic
commit
065f4d20fb

+ 7 - 3
frameworks/JavaScript/express/mongodb-app.js

@@ -6,7 +6,11 @@ const cluster = require('cluster');
 const numCPUs = require('os').cpus().length;
 const express = require('express');
 const mongoose = require('mongoose');
-const conn = mongoose.connect('mongodb://tfb-database/hello_world');
+const connection = mongoose.createConnection('mongodb://tfb-database/hello_world',{
+  useNewUrlParser: true,
+  useUnifiedTopology: true,
+  useFindAndModify: false,
+});
 
 // Middleware
 const bodyParser = require('body-parser');
@@ -23,7 +27,7 @@ const WorldSchema = new mongoose.Schema({
 }, {
   collection: 'world'
 });
-const MWorld = mongoose.model('world', WorldSchema);
+const MWorld = connection.model('world', WorldSchema);
 
 const FortuneSchema = new mongoose.Schema({
   _id: Number,
@@ -31,7 +35,7 @@ const FortuneSchema = new mongoose.Schema({
 }, {
   collection: 'fortune'
 });
-const MFortune = mongoose.model('fortune', FortuneSchema);
+const MFortune = connection.model('fortune', FortuneSchema);
 
 if (cluster.isPrimary) {
   // Fork workers.

+ 6 - 1
frameworks/JavaScript/express/mysql-app.js

@@ -14,7 +14,12 @@ const bodyParser = require('body-parser');
 const sequelize = new Sequelize('hello_world', 'benchmarkdbuser', 'benchmarkdbpass', {
   host: 'tfb-database',
   dialect: 'mysql',
-  logging: false
+  logging: false,
+  pool: {
+    max: 50,
+    min: 0,
+    idle: 10000
+  }
 });
 
 const World = sequelize.define('world', {

+ 3 - 1
frameworks/JavaScript/express/postgresql-app.js

@@ -15,7 +15,9 @@ const sequelize = new Sequelize('hello_world', 'benchmarkdbuser', 'benchmarkdbpa
   dialect: 'postgres',
   logging: false,
   pool: {
-    min: 20, max: 20
+    max: 50,
+    min: 0,
+    idle: 10000
   }
 });