Skip to content

Commit 924f6eb

Browse files
committed
Update prod_mgt documentation for parallel processing features
Document the new multi-worker and parallel storage capabilities: - 02_CORE_FUNCTIONALITY.md: Add multi-worker architecture and parallel storage sections, update processing flow description - 06_DEPLOYMENT_OPERATIONS.md: Add CONSERVER_WORKERS, CONSERVER_PARALLEL_STORAGE, CONSERVER_START_METHOD env vars, update scaling strategies with memory optimization guidance - 09_ARCHITECTURE_DESIGN.md: Update architecture diagram to show worker processes and parallel storage, add detailed scalability design section - 10_ROADMAP_FUTURE.md: Update to v1.1, mark parallel processing features as completed - README.md: Add parallel processing to core capabilities, include worker configuration example
1 parent b76bd98 commit 924f6eb

5 files changed

Lines changed: 195 additions & 44 deletions

File tree

prod_mgt/02_CORE_FUNCTIONALITY.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,25 @@ The vCon (Voice Conversation) is the fundamental data structure that represents
7676
### Chain Architecture
7777
- **Ingress Lists**: Entry points for vCons
7878
- **Processing Links**: Sequential processing steps
79-
- **Storage Operations**: Persistence to backends
79+
- **Storage Operations**: Persistence to backends (with parallel write support)
8080
- **Egress Lists**: Output queues for processed vCons
8181

82+
### Multi-Worker Architecture
83+
The server supports parallel vCon processing through multiple worker processes:
84+
85+
- **Single Worker Mode** (default): Traditional single-threaded processing
86+
- **Multi-Worker Mode**: Multiple processes consuming from Redis queues concurrently
87+
- **Atomic Work Distribution**: Redis BLPOP ensures each vCon is processed by exactly one worker
88+
- **Graceful Shutdown**: Workers complete current vCon before exiting on SIGTERM/SIGINT
89+
90+
### Parallel Storage Operations
91+
When multiple storage backends are configured, writes can execute concurrently:
92+
93+
- **ThreadPoolExecutor**: Concurrent writes to all storage backends
94+
- **Independent Failures**: One backend failure doesn't block others
95+
- **Significant Speedup**: 3-4x faster with multiple I/O-bound backends
96+
- **Configurable**: Can be disabled for sequential writes if needed
97+
8298
### Chain Configuration Example
8399
```yaml
84100
chains:
@@ -91,6 +107,7 @@ chains:
91107
storages:
92108
- postgres # Primary storage
93109
- s3 # Backup storage
110+
- milvus # Vector storage (all written in parallel)
94111
ingress_lists:
95112
- main_ingress
96113
egress_lists:
@@ -100,10 +117,11 @@ chains:
100117
101118
### Processing Flow
102119
1. vCon enters via ingress list
103-
2. Each link processes sequentially
104-
3. Storage operations execute
105-
4. vCon moves to egress lists
106-
5. Dead letter queue for failures
120+
2. Worker atomically pops vCon from queue (BLPOP)
121+
3. Each link processes sequentially within the worker
122+
4. Storage operations execute (parallel or sequential based on config)
123+
5. vCon moves to egress lists
124+
6. Dead letter queue for failures
107125
108126
## API Functionality
109127

prod_mgt/06_DEPLOYMENT_OPERATIONS.md

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,32 @@ GROQ_API_KEY=gsk-key
140140
VCON_REDIS_EXPIRY=3600
141141
VCON_INDEX_EXPIRY=86400
142142
TICK_INTERVAL=5000
143+
144+
# Worker configuration (parallel processing)
145+
CONSERVER_WORKERS=4 # Number of worker processes (default: 1)
146+
CONSERVER_PARALLEL_STORAGE=true # Enable parallel storage writes (default: true)
147+
CONSERVER_START_METHOD=fork # Multiprocessing method: fork, spawn, forkserver (default: platform)
143148
```
144149

150+
### Worker Configuration Details
151+
152+
#### CONSERVER_WORKERS
153+
- **Default**: 1 (single-threaded mode)
154+
- **Recommended**: Number of CPU cores for I/O-bound workloads
155+
- Workers atomically consume from Redis queues via BLPOP
156+
- Each worker processes vCons independently
157+
158+
#### CONSERVER_PARALLEL_STORAGE
159+
- **Default**: true (enabled)
160+
- When multiple storage backends configured, writes execute concurrently
161+
- Set to "false" for sequential storage writes
162+
163+
#### CONSERVER_START_METHOD
164+
- **"fork"**: Copy-on-write memory sharing (Unix only, fastest startup)
165+
- **"spawn"**: Fresh Python interpreter per worker (safer, higher memory)
166+
- **"forkserver"**: Hybrid approach using a clean forked server
167+
- **Empty/unset**: Use platform default (fork on Unix, spawn on Windows/macOS)
168+
145169
### Configuration File Structure
146170
```yaml
147171
# config.yml
@@ -167,31 +191,63 @@ chains:
167191
## Scaling Strategies
168192
169193
### Horizontal Scaling
170-
1. **Stateless Workers**: Scale conserver instances
171-
2. **Queue Distribution**: Redis-based load balancing
172-
3. **Storage Scaling**: Distributed storage backends
173-
4. **Cache Scaling**: Redis cluster mode
194+
1. **Multi-Worker Mode**: Scale workers within a single instance via CONSERVER_WORKERS
195+
2. **Multi-Instance**: Scale conserver instances across hosts
196+
3. **Queue Distribution**: Redis BLPOP provides atomic load balancing
197+
4. **Storage Scaling**: Distributed storage backends
198+
5. **Cache Scaling**: Redis cluster mode
174199
175200
### Vertical Scaling
176201
1. **Resource Allocation**: CPU and memory limits
177-
2. **Connection Pooling**: Database connections
178-
3. **Batch Processing**: Larger batch sizes
179-
4. **Caching**: Increase cache sizes
202+
2. **Worker Count**: Increase CONSERVER_WORKERS for more parallelism
203+
3. **Connection Pooling**: Database connections
204+
4. **Parallel Storage**: Enable concurrent storage writes
205+
5. **Caching**: Increase cache sizes
180206
181207
### Performance Optimization
208+
```bash
209+
# High-throughput configuration
210+
CONSERVER_WORKERS=8 # 8 parallel workers
211+
CONSERVER_PARALLEL_STORAGE=true # Concurrent storage writes
212+
CONSERVER_START_METHOD=fork # Memory-efficient on Unix
213+
```
214+
182215
```yaml
183-
# Optimized configuration
216+
# Optimized chain configuration
184217
chains:
185218
high_performance:
186219
links:
187220
- sampler: # Process 10% sample
188221
rate: 0.1
189222
- deepgram_link:
190223
batch_size: 50
191-
workers: 8
224+
storages:
225+
- postgres # All written in parallel
226+
- s3
227+
- milvus
192228
timeout: 300
193229
```
194230
231+
### Memory Optimization for Multi-Worker
232+
233+
When running multiple workers, memory management is important:
234+
235+
| Start Method | Memory Usage | Best For |
236+
|-------------|--------------|----------|
237+
| fork | Lower (copy-on-write) | Unix servers with stable libraries |
238+
| spawn | Higher (fresh interpreter) | macOS, Windows, or when using CUDA/OpenSSL |
239+
| forkserver | Medium (clean fork) | Balance of memory and safety |
240+
241+
```bash
242+
# Memory-efficient configuration (Unix)
243+
CONSERVER_WORKERS=4
244+
CONSERVER_START_METHOD=fork
245+
246+
# Safe configuration (any platform)
247+
CONSERVER_WORKERS=4
248+
CONSERVER_START_METHOD=spawn
249+
```
250+
195251
## Monitoring & Observability
196252

197253
### Metrics Collection

prod_mgt/09_ARCHITECTURE_DESIGN.md

Lines changed: 84 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,33 @@
2828
└────────┬────────┘
2929
3030
31-
┌─────────────────────────────────────────────────────────────┐
32-
│ Processing Pipeline │
33-
│ ┌─────────────┐ ┌─────────────┐ ┌──────────────────┐ │
34-
│ │Chain Manager│ │Link Executor│ │Storage Dispatcher│ │
35-
│ └─────────────┘ └─────────────┘ └──────────────────┘ │
36-
└────────┬───────────────┬───────────────────┬───────────────┘
37-
│ │ │
38-
▼ ▼ ▼
39-
┌─────────────┐ ┌─────────────────┐ ┌──────────────────┐
40-
│Redis Queue │ │ Link Modules │ │Storage Adapters │
41-
│ & Cache │ │ ┌───────────┐ │ │ ┌──────────────┐ │
42-
│┌───────────┐│ │ │Deepgram │ │ │ │ PostgreSQL │ │
43-
││ Ingress ││ │ │Analyze │ │ │ │ S3 │ │
44-
││ Egress ││ │ │Webhook │ │ │ │ Elasticsearch│ │
45-
││ DLQ ││ │ │Tag Router │ │ │ │ Milvus │ │
46-
│└───────────┘│ │ └───────────┘ │ │ └──────────────┘ │
47-
└─────────────┘ └─────────────────┘ └──────────────────┘
31+
┌─────────────────────────────────────────────────────────────────────┐
32+
│ Processing Pipeline (Multi-Worker) │
33+
│ ┌─────────────┐ ┌─────────────┐ ┌──────────────────────────┐ │
34+
│ │Chain Manager│ │Link Executor│ │Storage Dispatcher │ │
35+
│ └─────────────┘ └─────────────┘ │(ThreadPoolExecutor) │ │
36+
│ └──────────────────────────┘ │
37+
│ ┌─────────────────────────────────────────────────────────────┐ │
38+
│ │ Worker Processes (CONSERVER_WORKERS) │ │
39+
│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
40+
│ │ │Worker-1 │ │Worker-2 │ │Worker-3 │ │Worker-N │ │ │
41+
│ │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │ │
42+
│ │ └────────────┴────────────┴────────────┘ │ │
43+
│ │ │ BLPOP (atomic) │ │
44+
│ └─────────────────────────┼───────────────────────────────────┘ │
45+
└────────────────────────────┼──────────────────────────────────────┘
46+
47+
┌───────────────────┴───────────────────┐
48+
▼ ▼
49+
┌─────────────┐ ┌─────────────────┐ ┌──────────────────────────┐
50+
│Redis Queue │ │ Link Modules │ │Storage Adapters │
51+
│ & Cache │ │ ┌───────────┐ │ │(Parallel Writes) │
52+
│┌───────────┐│ │ │Deepgram │ │ │ ┌────────┬────────────┐ │
53+
││ Ingress ││ │ │Analyze │ │ │ │Postgres│ S3 │ │
54+
││ Egress ││ │ │Webhook │ │ │ ├────────┼────────────┤ │
55+
││ DLQ ││ │ │Tag Router │ │ │ │Elastic │ Milvus │ │
56+
│└───────────┘│ │ └───────────┘ │ │ └────────┴────────────┘ │
57+
└─────────────┘ └─────────────────┘ └──────────────────────────┘
4858
```
4959

5060
### Component Architecture
@@ -133,17 +143,66 @@ Processed vCon → Egress Queue → External Systems
133143

134144
## Scalability Design
135145

146+
### Multi-Worker Processing
147+
The server supports multiple parallel worker processes for improved throughput:
148+
149+
```
150+
┌─────────────────────────────────────────────────────────┐
151+
│ Main Process │
152+
│ - Spawns N worker processes (CONSERVER_WORKERS) │
153+
│ - Monitors worker health, restarts on failure │
154+
│ - Handles graceful shutdown (SIGTERM/SIGINT) │
155+
└────────────────────────┬────────────────────────────────┘
156+
157+
┌────────────────────┼────────────────────┐
158+
▼ ▼ ▼
159+
┌─────────┐ ┌─────────┐ ┌─────────┐
160+
│Worker-1 │ │Worker-2 │ │Worker-N │
161+
│ (PID A) │ │ (PID B) │ │ (PID N) │
162+
└────┬────┘ └────┬────┘ └────┬────┘
163+
│ │ │
164+
└──────────────────┴──────────────────┘
165+
166+
▼ BLPOP (atomic)
167+
┌──────────────┐
168+
│ Redis Queues │
169+
└──────────────┘
170+
```
171+
172+
**Key Features:**
173+
- **Atomic Distribution**: Redis BLPOP ensures each vCon is processed by exactly one worker
174+
- **Process Isolation**: Worker crashes don't affect other workers
175+
- **Graceful Shutdown**: Workers complete current vCon before exiting
176+
- **Auto-Restart**: Main process restarts failed workers
177+
178+
### Parallel Storage Operations
179+
When multiple storage backends are configured, writes execute concurrently:
180+
181+
```python
182+
# Sequential (old): ~400ms for 4 backends @ 100ms each
183+
for storage in storages:
184+
storage.save(vcon)
185+
186+
# Parallel (new): ~100ms for 4 backends @ 100ms each
187+
with ThreadPoolExecutor(max_workers=len(storages)) as executor:
188+
futures = [executor.submit(s.save, vcon) for s in storages]
189+
for future in as_completed(futures):
190+
future.result()
191+
```
192+
136193
### Horizontal Scaling
137-
1. **Stateless Workers**: No session state
138-
2. **Queue-Based Distribution**: Redis list operations
139-
3. **Shared Nothing Architecture**: Independent instances
140-
4. **Load Balancing**: Round-robin or least-connections
194+
1. **Multi-Worker Mode**: Scale within instance via CONSERVER_WORKERS
195+
2. **Multi-Instance**: Scale instances across hosts
196+
3. **Queue-Based Distribution**: Redis BLPOP for atomic work distribution
197+
4. **Shared Nothing Architecture**: Independent worker processes
198+
5. **Load Balancing**: Redis queues provide natural load balancing
141199

142200
### Vertical Scaling
143-
1. **Resource Pooling**: Connection pools
144-
2. **Batch Processing**: Bulk operations
145-
3. **Caching Strategy**: Multi-tier caching
146-
4. **Async Operations**: Non-blocking I/O
201+
1. **Worker Count**: Increase CONSERVER_WORKERS for more parallelism
202+
2. **Resource Pooling**: Connection pools per worker
203+
3. **Parallel Storage**: Concurrent writes to multiple backends
204+
4. **Caching Strategy**: Multi-tier caching
205+
5. **Start Method Selection**: Choose fork/spawn based on memory needs
147206

148207
### Database Design
149208

prod_mgt/10_ROADMAP_FUTURE.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Roadmap & Future Development
22

3-
## Current State (v1.0)
3+
## Current State (v1.1)
44

55
### Established Features
66
- ✅ Core vCon data model implementation
@@ -13,6 +13,14 @@
1313
- ✅ Dead letter queue handling
1414
- ✅ Search functionality
1515

16+
### New in v1.1: Parallel Processing
17+
-**Multi-Worker Support**: Configurable worker processes (CONSERVER_WORKERS)
18+
-**Parallel Storage Writes**: Concurrent storage operations (CONSERVER_PARALLEL_STORAGE)
19+
-**Configurable Start Method**: fork/spawn/forkserver selection (CONSERVER_START_METHOD)
20+
-**Graceful Shutdown**: Workers complete current vCon on SIGTERM/SIGINT
21+
-**Worker Auto-Restart**: Main process monitors and restarts failed workers
22+
-**Memory Optimization**: Deferred module imports for spawn start method
23+
1624
## Short-Term Roadmap (Q1-Q2 2024)
1725

1826
### Performance Enhancements

prod_mgt/README.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ Product roadmap, planned features, community requests, and long-term vision for
4545

4646
### Core Capabilities
4747
- 🎯 **Flexible Processing Pipeline**: Chain-based architecture with modular components
48-
- 🗄️ **Multi-Storage Support**: 10+ backend storage options
48+
- 🗄️ **Multi-Storage Support**: 10+ backend storage options with parallel write support
4949
- 🤖 **AI Integration**: Built-in support for transcription and analysis
5050
- 🔍 **Advanced Search**: Query by phone, email, name, and metadata
51-
- 📊 **Scalable Architecture**: Horizontal and vertical scaling options
51+
- 📊 **Scalable Architecture**: Multi-worker processing with configurable parallelism
52+
-**High Performance**: Parallel storage writes and multi-process vCon processing
5253

5354
### Processing Links
5455
- **Transcription**: Deepgram, Whisper (Groq/Hugging Face)
@@ -65,6 +66,14 @@ Product roadmap, planned features, community requests, and long-term vision for
6566

6667
## Configuration Examples
6768

69+
### Worker Configuration (Environment Variables)
70+
```bash
71+
# Enable parallel processing
72+
CONSERVER_WORKERS=4 # Run 4 worker processes
73+
CONSERVER_PARALLEL_STORAGE=true # Parallel writes to storage backends
74+
CONSERVER_START_METHOD=fork # Memory-efficient forking (Unix)
75+
```
76+
6877
### Basic Pipeline
6978
```yaml
7079
chains:
@@ -77,7 +86,7 @@ chains:
7786
- postgres # Store
7887
```
7988
80-
### Advanced Pipeline
89+
### Advanced Pipeline with Parallel Storage
8190
```yaml
8291
chains:
8392
advanced_chain:
@@ -93,10 +102,11 @@ chains:
93102
rules:
94103
- sentiment: positive
95104
queue: satisfied_customers
96-
storages:
105+
storages: # All written in parallel
97106
- postgres # Primary
98107
- s3 # Archive
99108
- elasticsearch # Search
109+
- milvus # Vector search
100110
```
101111
102112
## Support & Resources

0 commit comments

Comments
 (0)