i am working on a SaaS project that provides some services that people can call via API. My problem is how do I build the billing algorithm. I want to charge on every call to the service.
Now I'm looking for ways to make the call faster and I fear adding a billing algorithm to would make it slower. Because the billing has to access database and all.
Also from my understanding it's best to use queue for any other job not required by the user. So I'm thinking of adding the billing algorithm to a queue.
But that would mean, having like millions of jobs in queues for my rabbitMq, which can loose data, and if I loose data, I loose money.
Please would like an input on how I should structure the billing system. Would also like to know I'm I just too concerned about speed and I should just put the billing algorithm in the same API call.