Skip to content

Comments

Fix concurrent access issues causing Bad Gateway errors#9

Merged
BenCretois merged 1 commit intomainfrom
map_zoom
Sep 26, 2025
Merged

Fix concurrent access issues causing Bad Gateway errors#9
BenCretois merged 1 commit intomainfrom
map_zoom

Conversation

@BenCretois
Copy link
Collaborator

Major improvements for multi-user access:

Root Cause Analysis:

  • Streamlit @st.cache_data with _self parameter was causing cache key conflicts
  • Shared temporary file dictionary caused resource conflicts between sessions
  • No proper session isolation for concurrent users

Solutions Implemented:

  1. Enhanced Cache Isolation:

    • Added unique cache keys based on file paths and parameters
    • Maintains instance method pattern while fixing cache conflicts
    • Each user session gets properly isolated cache entries
  2. Session-Specific Temp Files:

    • Added session-specific prefixes for temporary files
    • Prevents file conflicts between concurrent users
    • Auto-cleanup remains intact per session
  3. Session Management:

    • Added UUID-based session IDs in main app
    • Improved Streamlit configuration for concurrent users
    • Better connection handling and caching settings
  4. Service Layer Fixes:

    • Fixed DataService, AudioService, and SiteMetadataService
    • Maintained backward compatibility with existing API
    • Proper error handling for concurrent operations

Configuration Updates:

  • Enhanced .streamlit/config.toml for better concurrent handling
  • Disabled usage stats to reduce potential race conditions
  • Improved message size and upload limits

Impact:

  • ✅ Eliminates Bad Gateway errors when multiple users access dashboard
  • ✅ Each user session is properly isolated
  • ✅ Maintains all existing functionality
  • ✅ Better performance under concurrent load
  • ✅ Backward compatible API

The dashboard now supports multiple concurrent users without conflicts!

Major improvements for multi-user access:

**Root Cause Analysis:**
- Streamlit @st.cache_data with _self parameter was causing cache key conflicts
- Shared temporary file dictionary caused resource conflicts between sessions
- No proper session isolation for concurrent users

**Solutions Implemented:**

1. **Enhanced Cache Isolation:**
   - Added unique cache keys based on file paths and parameters
   - Maintains instance method pattern while fixing cache conflicts
   - Each user session gets properly isolated cache entries

2. **Session-Specific Temp Files:**
   - Added session-specific prefixes for temporary files
   - Prevents file conflicts between concurrent users
   - Auto-cleanup remains intact per session

3. **Session Management:**
   - Added UUID-based session IDs in main app
   - Improved Streamlit configuration for concurrent users
   - Better connection handling and caching settings

4. **Service Layer Fixes:**
   - Fixed DataService, AudioService, and SiteMetadataService
   - Maintained backward compatibility with existing API
   - Proper error handling for concurrent operations

**Configuration Updates:**
- Enhanced .streamlit/config.toml for better concurrent handling
- Disabled usage stats to reduce potential race conditions
- Improved message size and upload limits

**Impact:**
- ✅ Eliminates Bad Gateway errors when multiple users access dashboard
- ✅ Each user session is properly isolated
- ✅ Maintains all existing functionality
- ✅ Better performance under concurrent load
- ✅ Backward compatible API

The dashboard now supports multiple concurrent users without conflicts!
@BenCretois BenCretois merged commit 56c7559 into main Sep 26, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant