Worker Billing Statistics

I am building a service leveraging workers that connect to databases (an HTTP gateway to a database). The worker post-processes database results, meaning it is possible to consume more CPU time to process larger result sets. I would like to meter “expensive” requests in order to bill users for their share of the computing resources consumed.

In an ideal world, our worker code would identify itself with an ID representing which user ran the request. At the end of the month, I would like to calculate the request times in order to calculate a bill.

Alternatively, I would be happy if we could at least access some sort of metrics for each worker execution. For example, if the worker takes 15 GB-S, I’d like to know… even if that were within the worker (i.e. our app could tally the requests in KV or an alternative store).

Additionally, I would like to track these kinds of requests to help users identify bottlenecks in their usage of the service. Often times inefficient SQL queries can lead to excessive use, signaled by higher CPU usage.

Bottom line: is there any way to break down/access worker execution statistics?

Totally agree with you. Cloudflare’s billing is one of the many reasons Amazon is still #1.