{"id":29016438,"url":"https://github.com/ysskrishna/express-fastapi-performance-test","last_synced_at":"2026-04-02T01:02:56.743Z","repository":{"id":300828752,"uuid":"1006383924","full_name":"ysskrishna/express-fastapi-performance-test","owner":"ysskrishna","description":"A comprehensive performance benchmark comparing FastAPI (sync vs. async) and Express.js. This project uses Artillery.io to simulate various real-world load testing scenarios (read/write-heavy, stress, spike) in a controlled Docker environment. It provides automated scripts, detailed performance reports, and a Looker Studio to visualize results.","archived":false,"fork":false,"pushed_at":"2025-06-23T19:55:06.000Z","size":1383,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-23T20:40:27.441Z","etag":null,"topics":["artilleryio","async","benchmark-framework","docker","docker-compose","express","expressjs","fastapi","load-testing","nodejs","performance-testing","postgresql","python","ysskrishna"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ysskrishna.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-06-22T06:24:45.000Z","updated_at":"2025-06-23T19:55:09.000Z","dependencies_parsed_at":"2025-06-23T20:50:42.317Z","dependency_job_id":null,"html_url":"https://github.com/ysskrishna/express-fastapi-performance-test","commit_stats":null,"previous_names":["ysskrishna/express-fastapi-performance-test"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ysskrishna/express-fastapi-performance-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysskrishna%2Fexpress-fastapi-performance-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysskrishna%2Fexpress-fastapi-performance-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysskrishna%2Fexpress-fastapi-performance-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysskrishna%2Fexpress-fastapi-performance-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ysskrishna","download_url":"https://codeload.github.com/ysskrishna/express-fastapi-performance-test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ysskrishna%2Fexpress-fastapi-performance-test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31293631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["artilleryio","async","benchmark-framework","docker","docker-compose","express","expressjs","fastapi","load-testing","nodejs","performance-testing","postgresql","python","ysskrishna"],"created_at":"2025-06-25T22:08:27.797Z","updated_at":"2026-04-02T01:02:56.699Z","avatar_url":"https://github.com/ysskrishna.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastAPI vs Express Performance Test\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Docker](https://img.shields.io/badge/docker-%230db7ed.svg?style=flat\u0026logo=docker\u0026logoColor=white)](https://www.docker.com/)\n[![Node.js](https://img.shields.io/badge/Node.js-339933?style=flat\u0026logo=nodedotjs\u0026logoColor=white)](https://nodejs.org)\n[![Python](https://img.shields.io/badge/Python-3776AB?style=flat\u0026logo=python\u0026logoColor=white)](https://www.python.org)\n[![FastAPI](https://img.shields.io/badge/FastAPI-005571?style=flat\u0026logo=fastapi)](https://fastapi.tiangolo.com)\n[![Express.js](https://img.shields.io/badge/Express.js-000000?style=flat\u0026logo=express\u0026logoColor=white)](https://expressjs.com)\n[![Artillery](https://img.shields.io/badge/Artillery-2.0.21-FF0000?style=flat\u0026logo=artillery\u0026logoColor=white)](https://artillery.io)\n[![Looker](https://img.shields.io/badge/Looker-4285F4?style=flat\u0026logo=looker\u0026logoColor=white)](https://lookerstudio.google.com/reporting/270e16b6-8831-41d5-aed0-4d2352b39218/page/pqwOF)\n\nThis project compares the performance of three different backend implementations:\n- FastAPI (Synchronous)\n- FastAPI (Asynchronous)\n- Express.js\n\nThe comparison is done through load testing using [Artillery.io](https://www.artillery.io/), measuring response times, throughput, and error rates under various load conditions.\n\n## Project Structure\n\n```\n.\n├── fastapi_sync/     # Synchronous FastAPI implementation\n├── fastapi_async/    # Asynchronous FastAPI implementation\n├── express/          # Express.js implementation\n├── postgres/         # Database initialization scripts\n├── artillery_tests/  # Load testing configuration and scripts\n├── documentation/    # Example reports and analysis\n└── docker-compose.yml\n```\n\n## Prerequisites\n\n- Docker and Docker Compose\n- Node.js (for running Artillery)\n- [Artillery.io](Artillery.io) (version 2.0.21)\n\n## Docker Compose Profiles\n\nThis project uses Docker Compose profiles to manage different service configurations. Profiles allow us to run specific sets of services without starting the entire stack. The following profiles are defined:\n\n- `fastapi-sync`: Runs the synchronous FastAPI implementation with PostgreSQL\n- `fastapi-async`: Runs the asynchronous FastAPI implementation with PostgreSQL\n- `express`: Runs the Express.js implementation with PostgreSQL\n\nEach profile can be activated using the `--profile` flag with `docker compose` commands. For example:\n```bash\ndocker compose --profile fastapi-sync up\n```\n\nThis approach allows us to:\n- Run different implementations independently\n- Compare performance without interference\n- Save resources by only running necessary services\n- Maintain clean separation between different implementations\n\n## Resource Limitations\n\nEach service in this project is configured with the following resource constraints:\n- CPU: Limited to 0.5 cores (50% of a single CPU core)\n- Memory: Limited to 512MB RAM\n\nThese limitations ensure:\n- Fair comparison between different implementations\n- Controlled resource usage during load testing\n- Consistent performance measurements\n- Prevention of resource exhaustion\n\n## Setup\n\n1. Install Artillery globally:\n```bash\nnpm install -g artillery@2.0.21\nnpm install -g artillery-plugin-metrics-by-endpoint\nartillery version \n```\n\nhttps://www.artillery.io/docs/get-started/get-artillery\n\n## Load Testing\n\nThe project includes a comprehensive load testing suite using Artillery.io that simulates various real-world scenarios:\n\n### 🔬 Test Scenarios\n\n#### 1. **Read-Heavy Test**\n* Simulates high-volume `GET` requests\n* Includes random pagination and optional filtering\n* Evaluates system performance under **read-intensive workloads**\n* Identifies latency trends and potential bottlenecks in read paths\n\n#### 2. **Write-Heavy Test**\n* Simulates concurrent `POST`, `PUT`, and `DELETE` operations\n* Stress-tests the database's write throughput\n* Measures system stability and responsiveness under **write-heavy traffic**\n* Useful for tuning **transactions, indexing, and batch inserts**\n\n#### 3. **Spike Test**\n* Introduces **sudden, large spikes in traffic**\n* Tests the system's elasticity and autoscaling behavior (if any)\n* Measures degradation in response time and error rates during and after spikes\n* Helps validate rate limiting and failover mechanisms\n\n#### 4. **Stress Test**\n* Gradually increases the load to **identify system breaking points**\n* Helps expose:\n  * Memory or CPU bottlenecks\n  * Slow database queries\n  * Throughput limits\n* Evaluates how the system **recovers** after hitting its limits\n\n#### 5. **Soak Test**\n* Simulates **continuous moderate load** over an extended duration\n* Detects issues like:\n  * Memory leaks\n  * Connection pool exhaustion\n  * Resource starvation over time\n* Helps validate system **stability and reliability** for long-running deployments\n\n#### 6. **Breakpoint-Read Test**\n* Incrementally increases the number of **read (`GET`) requests**\n* Identifies the exact point where:\n  * **Response times degrade**\n  * **Error rates increase**\n* Useful for testing:\n  * **Caching mechanisms**\n  * **Database read pools**\n  * **Horizontal read scaling limits**\n\n#### 7. **Breakpoint-Write Test**\n* Gradually increases the number of **write operations (`POST`, `PUT`, `DELETE`)**\n* Identifies the load threshold where:\n  * **Writes start failing or slowing down**\n  * **CPU, memory, or DB locks become critical**\n* Helps optimize:\n  * **Write throughput**\n  * **Transaction handling**\n  * **Concurrency limits**\n\n### Running Tests\n\nThe project includes an automated test runner script (`run_artillery_test.sh`) that handles:\n- Service orchestration using Docker Compose\n- Test execution with Artillery.io\n- Report generation in both JSON and HTML formats\n- Automatic cleanup of test resources\n\n#### Usage\n\n```bash\n./run_artillery_test.sh \u003cprofile\u003e \u003ctest-type\u003e\n```\n\nAvailable profiles:\n- `fastapi-sync`: FastAPI with synchronous operations\n- `fastapi-async`: FastAPI with asynchronous operations\n- `express`: Express.js implementation\n\nAvailable test types:\n- `read-heavy`: Read-intensive workload simulation\n- `write-heavy`: Write-intensive workload simulation\n- `spike`: Sudden traffic spike simulation\n- `stress`: Sustained high load testing\n- `soak`: Long-running stability test\n- `breakpoint-read`: Read operation threshold testing\n- `breakpoint-write`: Write operation threshold testing\n\nExample:\n```bash\n# Run read-heavy test on FastAPI async implementation\n./run_artillery_test.sh fastapi-async read-heavy\n```\n\n#### Running All Tests\n\nThe project also includes a `run_all_artillery_tests.sh` script to execute the entire test suite. This script will:\n- Iterate through all profiles (`fastapi-sync`, `fastapi-async`, `express`).\n- Run every test type for each profile.\n- Generate a summary report at the end.\n\nThis is useful for comprehensive performance validation across all implementations.\n\nUsage:\n```bash\n./run_all_artillery_tests.sh\n```\n\n### Test Reports\n\nTest results are automatically generated in two formats:\n1. JSON reports (`artillery_tests/reports/\u003cprofile\u003e-\u003ctest-type\u003e.json`)\n   - Detailed metrics and raw data\n   - Suitable for programmatic analysis\n   - Contains timing, error rates, and throughput data\n\n2. HTML reports (`artillery_tests/reports/\u003cprofile\u003e-\u003ctest-type\u003e-report.html`)\n   - Visual representation of test results\n   - Interactive charts and graphs\n   - Summary statistics and key metrics\n\n### Test Configuration\n\nEach test scenario is configured in YAML files under the `artillery_tests` directory:\n- `read-heavy-test.yml`: Read operation simulation\n- `write-heavy-test.yml`: Write operation simulation\n- `spike-test.yml`: Traffic spike simulation\n- `stress-test.yml`: Sustained load testing\n- `soak-test.yml`: Long-running stability test\n- `breakpoint-read-test.yml`: Read operation threshold testing\n- `breakpoint-write-test.yml`: Write operation threshold testing\n\nThe test configurations can be customized to adjust:\n- Virtual user count\n- Request rates\n- Test duration\n- Endpoint patterns\n- Custom scenarios and functions\n\n## Monitoring\n\nMonitor Docker container resources during tests:\n```bash\ndocker stats\n```\n\n## Cleanup\n\nTo stop and remove all containers and volumes:\n```bash\ndocker compose down -v\n```\n\n## Documentation and Reports\n\nThis project provides comprehensive documentation and pre-generated reports in the `documentation/` directory.\n\n### Interactive Dashboard\n\nAn interactive dashboard for visualizing and comparing performance metrics is available on Looker Studio.\n\n- **Public URL**: [View the Performance Dashboard](https://lookerstudio.google.com/reporting/270e16b6-8831-41d5-aed0-4d2352b39218/page/pqwOF)\n\nHere's a snapshot of what an Looker Dashboard looks like:\n\n![Looker Dashboard](./documentation/looker/report_dashboard.png)\n\nA Looker Dashboard PDF version can be downloaded [here](./documentation/looker/report_dashboard.pdf).\n\n\n### Artillery Reports\n\nReports for all test scenarios are available in `documentation/artillery_generated_reports`. These can serve as a reference for what to expect from your own test runs.\n\nHere's a snapshot of what an HTML report looks like:\n\n![Artillery Report Sample](./documentation/express-breakpoint-read-report-sample.png)\n\n\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n**Author:** [Siva Sai Krishna](https://github.com/ysskrishna)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fysskrishna%2Fexpress-fastapi-performance-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fysskrishna%2Fexpress-fastapi-performance-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fysskrishna%2Fexpress-fastapi-performance-test/lists"}