3 ms·
> However, that requires doing an extra lookup for every write on the most active / real time table. You only have to do that lookup once and you're likely loo
by withinboredom 4y ago
> However, that requires doing an extra lookup for every write on the most active / real time table.
You only have to do that lookup once and you're likely looking up other things to write that event as well. So it is almost a free cost. You can actually do all of this async and faster:
Just call a url containing all the details in the url (/usage?user_id=123&product_id=123&type=start_usage) that returns a 200 response with a minimal payload (0 byte static file). From there, just stream the server's access logs to Apache Kafka after the logs rotate once per minute to be parsed. There it will do all the lookups and aggregation. You're probably only looking at a delay of 4-5 minutes before the data is available to the end user -- even with millions of active users.
Then you can parse the logs async as fast/slow as you need to.