Solving a Realistic Problem


Solving a Realistic Problem

What are we building?


We run an API as a service and charge customers based on the number of calls that they make to the API. All calls to the API count the same and are not weighted differently.


We would also like to have a resolution of 5 minutes so that we can see how many API calls are made within a 5 minute window per customer.

Proposed Solution

We will create a simple supervision tree with two processes:

  • EventCollector - Collects and aggregates cast messages from a Phoenix Plug
  • EventFlusher - Flushes the aggregated messages from EventCollector and writes them to TimescaleDB every 5 minutes or sends them to another service
graph TD;
  classDef supervisor fill:#7dd3fc,stroke:#888;
  classDef process fill:#c4b5fd,stroke:#888;


  a --> b
  a --> c

<- Previous | Next ->