micro-analytics / micro-analytics-cli

Public analytics as a Node.js microservice. No sysadmin experience required! 📈
MIT License
735 stars 39 forks source link

atomicity and db operation concerns #40

Open sean-roberts opened 7 years ago

sean-roberts commented 7 years ago

So as a few people have brought up, we are mimicking locking in our pushView util function which seems to be doing the db adapter's job. For example, if a db solution supports a "add or increment" function or handles atomicity cross process, then we are introducing a performance bottleneck by having all adapters use our locks logic and 2-3 transaction inserts. For the record, I think it was a really good starting point but we should take it to the next level.

So, I think that the next phase of our adaptors, while there are only two, need to support the API that we provided but the put needs to be changed. If they need to manually call their this.has() and this.get() to reconcile what they need to do, then go for it, but we shouldn't force that. So we should change put (or possibly rename it) but we should give them the key and they need to resolve a promise with the count value.

What do you think?

mxstbr commented 7 years ago

Yeah, that makes sense imo. What do you think @relekang?

relekang commented 7 years ago

Sounds good to me 👌 It allows for much more custom optimisation for each adapter.