4 ms·
Building a Real-time SMS Voting App Part 1: Node.js and CouchDB
- benmmurphy 14y agodoes the vote counter get incremented atomically?
- crabasa 14y agoGood question. Incoming votes get added to an in-memory array, which is then periodically flushed to the DB. During the flush, incoming votes are queued-up and aren't processed until the flush to the DB is complete.
- shreyansj 14y agoDoes that mean that when you implement visualization of voting data (in Part 2), there will be a small delay between the votes that have been cast and the votes that are being visualized? I have no experience with socket.io, so I am just asking out of curiosity.
- crabasa 14y ago<<I really wish I could edit my comments>> Scratch my comment above, the caching and flushing is introduced in a future blog post. In this iteration of the code base, an attempt is made to save a vote to the DB. If it fails, it fails, there is no attempt to retry. https://github.com/crabasa/votr-part1/blob/master/events.js#L53 https://github.com/crabasa/votr-part1/blob/master/events.js#... A comment was made about whether the vote persistence would be considered ACID. Most likely not! Each vote that comes in fetches a copy of the event document. If votes came in fast enough, this would create a problem. However, rather than corrupting the data, I think the votes would simply fails since CouchDB uses a revision property to prevent this: http://wiki.apache.org/couchdb/Document_revisions?action=show&redirect=DocumentRevisions http://wiki.apache.org/couchdb/Document_revisions?action=sho...
- praveenhm 14y agoGood article on building the node.js stack.
- jjacobson 14y agoCarter, you are a bad ass for putting your code up on Hacker News.
- crabasa 14y agoI'm not sure I'm a badass, but I think it's hard for many developers to subject their code to public scrutiny, especially when it's with a language that's outside of their wheelhouse. I wrote this app to teach myself Node.js, CouchDB, Socket.io, HighCharts.js and bunch of other things that I really wanted to learn. I hope it's useful for people new to these things, and definitely appreciate all the feedback I'm getting from the community.
- viraj_shah 14y agoI'm anxiously waiting for the remaining parts. :)
- juanbyrge 14y agoWow you are a brilliant hacker. How did you get so goods?