Performance
Advanced performance tuning and scaling tips.
Performance
Advanced performance tuning and scaling tips.
Rate Limiting
The API service includes built-in rate limiting to protect against overload and ensure fair usage across clients. The system uses a simplified policy structure based on operation types and resource intensity.
Rate Limiting Policies
The following rate limiting policies are applied per user/IP address:
Policy | Operation Types | Requests per Second | Queue Limit | Description |
---|---|---|---|---|
Global | All endpoints | 1,000 | 200 | Safety net across all APIs |
Light Operations | GET single items, list operations | 100 | 50 | Low-impact read operations |
Medium Operations | Query API, batch reads | 50 | 25 | Moderate resource usage |
Heavy Operations | Create/Update/Delete operations | 20 | 10 | High-impact write operations |
Admin Operations | Model management, job operations | 50 per minute | 25 | Administrative functions |
Endpoint Classifications
- Light Operations: Digital twin GET, relationship GET, list operations
- Medium Operations: Query API for graph traversals and searches
- Heavy Operations: Digital twin CREATE/UPDATE/DELETE, relationship CREATE/UPDATE/DELETE
- Admin Operations: Model management, import job management
Configuration
All settings can be customized through the Parameters
section in appsettings.json
:
Environment Variable Support
All parameters support environment variable overrides using the pattern Parameters__<SettingName>
:
Error Response
When rate limits are exceeded, the API returns HTTP 429 with details:
PostgreSQL Performance Tuning
For optimal performance, especially when using Apache AGE with digital twins data, proper PostgreSQL configuration is crucial.
Cluster Configuration
When deploying PostgreSQL in a cluster (e.g., using CloudNativePG), consider these resource and storage configurations:
PostgreSQL Parameters
Key parameters for performance optimization:
Performance Recommendations
Memory Settings
- shared_buffers: Set to 25% of available RAM (512MB for 2GB systems)
- effective_cache_size: Set to 75% of total system memory
- work_mem: Start with 4MB, increase for complex queries
Connection Pool Settings
- max_connections: Match your application's connection pool size
- Connection pooling: Use PgBouncer or similar for high-concurrency scenarios
WAL and Checkpointing
- wal_compression: Use
lz4
for good compression with minimal CPU overhead - checkpoint_completion_target: Set to 0.9 to spread checkpoint I/O over time
- max_wal_size: Increase for write-heavy workloads to reduce checkpoint frequency
Storage Considerations
- Use SSD storage for both data and WAL files
- Separate WAL storage for better I/O performance
- Use premium storage classes in cloud environments
Monitoring and Optimization
Monitor these key metrics:
- Connection usage and pool efficiency
- Buffer hit ratio (target: >95%)
- Checkpoint frequency and duration
- WAL generation rate
- Query performance and slow query logs
Apache AGE Specific Tuning
For graph workloads with Apache AGE:
- Increase
work_mem
for complex graph traversals - Monitor memory usage during large graph operations
- Consider partitioning large graph datasets
- Use appropriate indexes on graph node and edge properties