MongoDB - Diagnosing Slow Loading Times

Use this page to diagnose slow performance on a MongoDB Instance.

Steps to Diagnose

  1. Update the FaceTec Server Dashboard to the latest version.
  2. If the behavior is not resolved via updating, please reproduce the slow-loading page.
  3. While the page is loading, use Mongo shell or a Mongo shell interface (Robo 3T, Studio 3T, etc) and run “db.currentOp({})”.  Copy and save this result to a .txt file.
  4. Using the Mongo shell or a Mongo shell interface, run some sample queries (Javascript example below) to benchmark performance.
  5. Finally, get the response date and the size of the response from the request.
    1. Click the Network tab and identify the request.
    2. On the request Right Click -> Copy -> Copy Response.
    3. Paste this into a text file and measure the size.

JavaScript Examples

Example queries for loading Liveness 3D, Enrollments, Match (3D:3D)


// Liveness 3D
var query = {"callData.path": "/liveness-3d"};

// Enrollment 3D
var query = {"callData.path": "/match-3d-3d"};

// Match 3D:3D
var query = {"callData.path": "/match-3d-3d"};

// Photo ID Match and Photo ID Scan
var query = {"callData.path":{"$in":["/match-3d-2d-idscan","/idscan-only"]}};

var projection = {"additionalSessionData":1,"ageEstimateGroupEnumInt":1,"ageEstimateGroupV2EnumInt":1,"ageV2GroupEnumInt":1,"ageCheckTargetEnumInt":1,"callData":1,"error":1,"faceScanSecurityChecks":1,"serverInfo":1,"success":1,"externalDatabaseRefID":1,"isOnFraudList":1,"fraudUserListSearchResult":1,"allUserEnrollmentsListSearchResult":1,"isLikelyOnFraudList":1,"isLikelyDuplicate":1,"enrollmentSession":1,"fullIDStatusEnumInt":1,"expectedMediaStatusEnumInt":1,"mrzStatusEnumInt":1,"matchLevel":1,"matchLevelNFCToFaceMap":1,"nfcStatusEnumInt":1,"nfcAuthenticationStatusEnumInt":1,"barcodeStatusEnumInt":1,"faceOnDocumentStatusEnumInt":1,"textOnDocumentStatusEnumInt":1,"scannedIDPhotoFaceFoundWithMinimumQuality":1,"didCompleteIDScanWithoutMatchingOCRTemplate":1,"didMatchIDScanToOCRTemplate":1,"isIDScanIncomplete":1,"didCompleteIDScanWithUnexpectedMedia":1,"unexpectedMediaEncounteredAtLeastOnce":1,"data.autoExtractedOCRData":1,"data.templateInfo":1,"data.nfcData":1,"data.barcodeData":1,"data.userConfirmedExtractedData":1}

var startTime = Date.now();
db.getCollection("Session").find(query,projection).skip(0).limit(100).sort({"callData.date": -1})
var endTime = Date.now();
console.log(`Execution time: ${endTime - startTime} ms`);

var startTime = Date.now();
db.getCollection("Session").find(query,projection).skip(100).limit(100).sort({"callData.date": -1})
var endTime = Date.now();
console.log(`Execution time: ${endTime - startTime} ms`);

var startTime = Date.now();
db.getCollection("Session").find(query,projection).skip(200).limit(100).sort({"callData.date": -1})
var endTime = Date.now();
console.log(`Execution time: ${endTime - startTime} ms`);

var startTime = Date.now();
db.getCollection("Session").find(query,projection).skip(500).limit(100).sort({"callData.date": -1})
var endTime = Date.now();
console.log(`Execution time: ${endTime - startTime} ms`);

var startTime = Date.now();
db.getCollection("Session").find(query,projection).skip(1000).limit(100).sort({"callData.date": -1})
var endTime = Date.now();
console.log(`Execution time: ${endTime - startTime} ms`);

Example query for loading Dashboard

var dashboardAggregatePipeline = [
    {
      $match: {
        "callData.path": {
          $in: [
            "/check-age-2d",
            "/check-age-3d",
            "/estimate-age-2d",
            "/estimate-age-3d",
            "/enrollment-3d",
            "/liveness-2d",
            "/liveness-3d",
            "/match-2d-2d",
            "/match-3d-2d-3rdparty-idphoto-low-quality",
            "/match-3d-2d-3rdparty-idphoto",
            "/match-3d-2d-face-portrait",
            "/match-3d-2d-idscan",
            "/idscan-only",
            "/match-3d-2d-profile-pic",
            "/match-3d-3d"]
        },
      },
    },
    {
      $group: {
        _id: {
          path: "$callData.path",
          year: { $year: "$callData.date" },
          month: { $month: "$callData.date" },
          day: { $dayOfMonth: "$callData.date" },
        },
        count: { $sum: {$cond: [ { $eq: ["$success", true ] }, 1, 0]} },
      },
    }
];

var startTime = Date.now();
db.getCollection("Session").aggregate(dashboardAggregatePipeline)
var endTime = Date.now();
console.log(`Execution time: ${endTime - startTime} ms`);