Velocity
Back to Examples
High Throughput

Real-Time
Event Analytics

Stream and aggregate millions of user events per second with sub-millisecond ingestion latency.

Ingestion Architecture

Collecting clickstream data or server logs requires a database that can handle intense write bursts without blocking. VelocityDB uses Atomic Increments and Time-Series Bucketing to aggregate data on-the-fly.

Hot Counters

Instantly increment global or scoped counters (e.g., page views, button clicks) without the overhead of read-modify-write cycles.

INCR site:total_views

Time Bucketing

Group events into time-based keys (minute/hour) to generate real-time trend charts with zero query latency.

HINCRBY stats:2024-02-10:14h clicks:home 1

Live Playground

Emit telemetry events and watch them get aggregated into high-performance buckets in sub-milliseconds.

H-Hash Ingestion Demo

Global Events4,195
Write Ops1.6M/s
Simulated Event Triggers

Telemetry Stream Ingest

Listening for telemetry events...
Aggregation StrategyAtomic Hash Map H-Sharding
1

Track Event (Frontend)

Emit an event whenever a user performs an action. Velocity's high throughput allows you to track everything without affecting application performance.

// Analytics Tracker Utility

async function trackClick(buttonId) {
  const timestamp = new Date().toISOString().substring(0, 13); // YYYY-MM-DD:HH
  
  // Send to our fast ingestion endpoint
  await fetch('/api/ingest', {
    method: 'POST',
    body: JSON.stringify({ 
      event: 'click', 
      id: buttonId,
      bucket: timestamp 
    })
  });
}
2

Atomic Ingestion (Backend)

Use `HINCRBY` to increment a specific field within a hash bucket. This is atomic and handles massive concurrency.

app.post('/api/ingest', async (req, res) => {
  const { event, id, bucket } = req.body;
  
  const key = `analytics:${bucket}`;
  const field = `${event}:${id}`;
  
  // Hyper-fast atomic increment
  await client.hincrby(key, field, 1);
  
  // Also update a global counter
  await client.incr('global:events_processed');
  
  res.status(202).send(); // Accepted
});
3

Real-time Dashboard Query

Fetch the pre-aggregated buckets to populate your charts. No expensive "SUM" or "GROUP BY" needed.

app.get('/api/dashboard', async (req, res) => {
  const buckets = getRecentBucketKeys(24); // Last 24 hours
  
  const results = await Promise.all(
    buckets.map(key => client.hgetall(key))
  );
  
  res.json({
    history: results,
    total: await client.get('global:events_processed')
  });
});

CLI Analytics

Increment Counter
INCR page_views
Hash Increment
HINCRBY day:1 clicks 5
Get All Stats
HGETALL day:1

Scale Tip

Use `PIPELINE` or `BATCH` mode to send multiple increments in a single network round-trip for even higher performance.