{"id":18035750,"url":"https://github.com/apanjwani0/node.js-benchmarking","last_synced_at":"2026-04-15T14:35:22.027Z","repository":{"id":259668700,"uuid":"861341017","full_name":"apanjwani0/Node.js-Benchmarking","owner":"apanjwani0","description":"Comparing Node.Js Server Side Calculation and MongoDB aggregate query","archived":false,"fork":false,"pushed_at":"2024-10-27T07:05:14.000Z","size":1750,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T08:11:09.300Z","etag":null,"topics":["aggregate","benchmarking","db-query","mongodb","mongoosejs","nodejs","server-side-processing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apanjwani0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-22T16:30:33.000Z","updated_at":"2024-10-27T07:05:18.000Z","dependencies_parsed_at":"2024-10-27T08:19:18.528Z","dependency_job_id":"c151e764-9835-4301-b1bf-ff3ba703bbcb","html_url":"https://github.com/apanjwani0/Node.js-Benchmarking","commit_stats":null,"previous_names":["apanjwani0/node.js-benchmarking"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apanjwani0%2FNode.js-Benchmarking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apanjwani0%2FNode.js-Benchmarking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apanjwani0%2FNode.js-Benchmarking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apanjwani0%2FNode.js-Benchmarking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apanjwani0","download_url":"https://codeload.github.com/apanjwani0/Node.js-Benchmarking/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247263801,"owners_count":20910465,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aggregate","benchmarking","db-query","mongodb","mongoosejs","nodejs","server-side-processing"],"created_at":"2024-10-30T12:09:27.882Z","updated_at":"2026-04-15T14:35:21.987Z","avatar_url":"https://github.com/apanjwani0.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js Benchmarking\n\nThis repository explores different approaches to data processing with Node.js and MongoDB. It focuses on comparing the performance of processing data at the database level versus the application level.\n\n## Overview\n\nWhen working with MongoDB, developers often face a choice between:\n1. Processing data in the application after filtering it from the database.\n2. Utilizing MongoDB's aggregation pipeline to handle transformations directly in the database.\n\nEach approach has its pros and cons:\n\n- Application-level processing is more flexible and easier to iterate on during development, but it can increase server CPU and memory load.\n- Database-level processing can significantly improve performance, especially with large datasets, but complex\n\nThis project benchmarks both approaches to help guide better decision-making in terms of performance and scalability.\n\n## Problem Statement\n\nThe project focuses on an API that retrieves data from a MongoDB collection containing 1.5 million documents. Each document includes details such as a person's name, email, country, and a randomly assigned indexField.\n\n- The indexField ranges between 1 and 100,000, resulting in an average of 15 documents per indexField.\n- The API is designed to return data within a given range of indexField values.\n- The response includes country-wise data, along with:\n- - Total Entries: The total number of documents for each country.\n- - Unique Entries: The number of unique email addresses for each country.\n\nThe goal is to explore which approach (database vs. application) provides better performance when scaling with large datasets.\n\n\n## Features\n\n- **Side-by-side comparisons**: Demonstrates how each approach works through clear, simple examples.\n- **Performance benchmarks**: Benchmarks both strategies on various dataset sizes, showcasing performance differences.\n- **Detailed results**: Provides a breakdown of results with clear, easy-to-interpret data.\n\n## Results\n\nFor detailed logs around the result, check out the logs in the [Screenshots README](./screenshots/README.md).\n\n## Getting Started\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/apanjwani0/MongoDB-Benchmarking.git\n2. Install Dependencies:\n    ```bash\n    npm install\n3. Configuration: \n    - Copy sample.env to .env:\n    - Edit .env: Fill in your configuration settings.\n4. Run the server\n    ```bash\n    npm run dev\n5. Hit the API with custom parameters:\n\n   - **For database-side processing:**\n     ```bash\n     curl --location 'http://localhost:3000/api/complexAggregation?min=1\u0026max=1000'\n     ```\n\n   - **For application-side processing:**\n     ```bash\n     curl --location 'http://localhost:3000/api/application/complexAggregation?min=1\u0026max=1000'\n     ```\n\n    #### Notes:\n    - Adjust the `min` and `max` parameters to set the range of data being processed.\n\n## Notes\n\n- Hit API multiple times, as db will cache the request.\n- Make sure of the limitations around DB query stage. \n- Use DB tools (like MongoDB Atlas) to fast-pace writing complex queries.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapanjwani0%2Fnode.js-benchmarking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapanjwani0%2Fnode.js-benchmarking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapanjwani0%2Fnode.js-benchmarking/lists"}