OLTP Template
oltp.yml is Pigsty’s default configuration template for online transaction processing (OLTP).
It is designed for CPUs with 4-128 cores and provides high concurrency, low latency, and high throughput.
Pair with
node_tune=oltpfor OS-level tuning.
Use Cases
Use the OLTP template for:
- E-commerce: Order processing, inventory, user transactions
- Social apps: User feeds, messaging, following relationships
- Gaming backends: Player data, leaderboards, game state
- SaaS applications: Multi-tenant business systems
- Web apps: CRUD-intensive workloads
Workload characteristics:
- Many short transactions (millisecond-level)
- High concurrent connections (hundreds to thousands)
- Read/write ratio typically 7:3 to 9:1
- Latency-sensitive, requires fast response
- High data consistency requirements
Usage
oltp.yml is the default template.
You do not need to select it explicitly:
To select it explicitly, use:
Parameter Details
Connection Management
- When
pg_default_service_destispgbouncer,max_connectionsis set to 500 - When traffic connects directly to PostgreSQL,
max_connectionsis set to 1000 - Override via
pg_max_connparameter
Memory Config
OLTP template memory allocation strategy:
| Parameter | Formula | Description |
|---|---|---|
shared_buffers | mem × pg_shared_buffer_ratio | Default ratio 0.25 |
maintenance_work_mem | shared_buffers × 25% | For VACUUM, CREATE INDEX |
work_mem | 64MB - 1GB | Based on shared_buffers/max_connections |
effective_cache_size | total mem - shared_buffers | Estimated cache memory |
work_mem calculation:
This calculation gives each connection sufficient sort/hash memory without excessive allocation.
Parallel Query
OLTP template moderately limits parallel queries to prevent resource contention:
Parallel cost estimates are increased to favor serial execution:
WAL Config
These settings balance data safety and write performance.
Vacuum Config
Conservative vacuum settings avoid impacting online transaction performance.
Query Optimization
These settings help the planner generate better query plans.
Logging & Monitoring
Client Timeouts
The 10-minute idle transaction timeout prevents inactive transactions from keeping locks indefinitely.
Extension Config
Template Comparison
| Feature | OLTP | OLAP | CRIT |
|---|---|---|---|
| max_connections | 500-1000 | 500 | 500-1000 |
| work_mem | 64MB-1GB | 64MB-8GB | 64MB-1GB |
| Parallel query | Moderate limit | Aggressive | Disabled |
| Vacuum intensity | Conservative | Aggressive | Conservative |
| Txn timeout | 10min | Disabled | 1min |
| Slow query threshold | 100ms | 1000ms | 100ms |
Why OLTP over OLAP?
- Queries are mostly simple point/range lookups
- Transaction response time requires milliseconds
- High concurrent connections
- No complex analytical queries
Why OLTP over CRIT?
- Small probability of data loss acceptable (async replication)
- Complete audit logs not required
- Better write performance desired
Performance Tuning Tips
Connection Pooling
For high concurrency, use PgBouncer connection pool:
Read Separation
Use read replicas to share read load:
Monitoring Metrics
Focus on these metrics:
- Connections: Active/waiting connection counts
- Transaction rate: TPS, commit/rollback ratio
- Response time: Query latency percentiles (p50/p95/p99)
- Lock waits: Lock wait time, deadlock counts
- Replication lag: Replica delay time and bytes
References
pg_conf: PostgreSQL config template selectionnode_tune: OS tuning template, should matchpg_conf- OLAP Template: Analytics template comparison
- CRIT Template: Critical business template comparison
- TINY Template: Micro instance template comparison
- Cluster Config: PostgreSQL cluster type configuration
- High Availability: HA architecture design
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)