Cube.dev APM Test

The easiest way to test this is by asking me to start the Codespaces environment and heading to one of these URLs:

Intro

This is my submission for the APM test project. The goals were:

  • get a cube.dev cluster running
  • write a metrics collector to record events from the API agent.
  • a dashboard for queries/minute and requests/minute.
  • production ready and horizontally scalable as much as possible.
  • 100 queries per second

My implementation:

  • I wrote a simple collector in Javascript using the Websocket API I found in the cubejs source.
  • The "REST API Request" events are written to the request table in pgSQL
  • The "query completed" events are written to the queries table in pgSQL
  • The dashboard is based off the D3 example, simplified a bit and with a built-in load generator.

For scalability:

  • It's possible to add more collectors, API servers, store workers, refresh workers and dashboard instances.
  • By default there are 4 API servers, since they seemed to be the bottleneck.
  • The cubestore uses MinIO to allow workers to be distributed over several systems.

Usage

  1. docker compose up -d
  2. Wait for the containers to build and the dashboard to start (it's the slowest part)
  3. Open dashboard at http://localhost:3000
  4. For load testing, you can set the Load parameter on the dashboard.
  5. The collector is running at ws://localhost:5000 if you want to point more sources at it.

Possible Future Improvements

To really make it production ready:

  • Put it on a real cluster (say in AWS)
  • Use k8s services
  • Use ingress / reverse-proxy
  • Use kustomize and terraform for setup.
  • Add health checks.
  • Use a login and real secrets.

To scale even more:

  • Replace postgreSQL with clustered DB.
  • Scale S3 service or use real S3.

TODO: Done

  • Create repo
  • Write docker-compose
  • Write Schema
  • Run basic cube cluster
  • Write collector
  • Write dashboard
    • queries/sec
    • requests/sec
    • top-10 queries by duration
  • Pre Aggregations
    • Add partitions
  • Disable devmode.

Feedback

There is a broken link here: