[PR #25617] feat(stress-test): add comprehensive stress testing suite using Locust #31134

Closed
opened 2026-02-21 20:48:53 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/25617

State: closed
Merged: Yes


Fixes #25616

Summary

This PR introduces a comprehensive stress testing suite for Dify using Locust, specifically designed to measure Server-Sent Events (SSE) streaming performance under various load conditions.

Key Components Added:

  1. Stress Test Framework (scripts/stress-test/)

    • SSE-optimized Locust benchmark implementation
    • Real-time metrics tracking for SSE connections
    • Automated setup and configuration scripts
  2. Mock OpenAI Server

    • Isolated testing environment without external dependencies
    • Consistent response times for reliable benchmarking
  3. Automated Setup Pipeline

    • Complete workflow app creation and configuration
    • API key generation and plugin installation
    • One-command setup with setup_all.py
  4. Performance Metrics

    • Active SSE connection monitoring
    • Time to First Event (TTFE) measurement
    • Event throughput tracking (events/sec)
    • Connection establishment rate (conn/sec)

What's Measured:

  • Primary endpoint: /v1/workflows/run with SSE streaming
  • Concurrency levels: 10 to 1000+ simultaneous users
  • Key metrics: TTFE, response time percentiles (P50/P95/P99), throughput
  • Real-time monitoring: Live updates every 5 seconds during tests

Usage:

# Setup (one-time)
python scripts/stress-test/setup_all.py

# Run stress test
./scripts/stress-test/run_locust_stress_test.sh

Production Deployment Guidance:

The suite includes comprehensive documentation on:

  • Gunicorn worker tuning for different load levels
  • System optimization for high concurrency
  • Performance troubleshooting guidelines

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/25617 **State:** closed **Merged:** Yes --- Fixes #25616 ## Summary This PR introduces a comprehensive stress testing suite for Dify using Locust, specifically designed to measure Server-Sent Events (SSE) streaming performance under various load conditions. ### Key Components Added: 1. **Stress Test Framework** (`scripts/stress-test/`) - SSE-optimized Locust benchmark implementation - Real-time metrics tracking for SSE connections - Automated setup and configuration scripts 2. **Mock OpenAI Server** - Isolated testing environment without external dependencies - Consistent response times for reliable benchmarking 3. **Automated Setup Pipeline** - Complete workflow app creation and configuration - API key generation and plugin installation - One-command setup with `setup_all.py` 4. **Performance Metrics** - Active SSE connection monitoring - Time to First Event (TTFE) measurement - Event throughput tracking (events/sec) - Connection establishment rate (conn/sec) ### What's Measured: - **Primary endpoint**: `/v1/workflows/run` with SSE streaming - **Concurrency levels**: 10 to 1000+ simultaneous users - **Key metrics**: TTFE, response time percentiles (P50/P95/P99), throughput - **Real-time monitoring**: Live updates every 5 seconds during tests ### Usage: ```bash # Setup (one-time) python scripts/stress-test/setup_all.py # Run stress test ./scripts/stress-test/run_locust_stress_test.sh ``` ### Production Deployment Guidance: The suite includes comprehensive documentation on: - Gunicorn worker tuning for different load levels - System optimization for high concurrency - Performance troubleshooting guidelines ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:48:53 -05:00
yindo closed this issue 2026-02-21 20:48:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31134