3 ms·
Yes, I wanted to ask you what the output was, because, as others have pointed out, that's probably the determining factor in how you should structure the data.
by mseebach 18y ago
Yes, I wanted to ask you what the output was, because, as others have pointed out, that's probably the determining factor in how you should structure the data.
If I understand correctly, when I post "A" and a short while later, I post "B", and in the meantime everyone else posts X posts, then at the time of posting B, I want to get a return of exactly X?
If that's the case, you should just keep a central counter, which is your critical region. Updating that 16.000 times a second in a blocking way should be possible. Sounds like something Erlang guys do to show off.
The rest of the app can be completely de-coupled. Once you've increased the counter, you save userid, timestamp and counter, and fetch the former post, and return the diff of the counter-values.
The only thing in this setup that's hard is the counter.
one other thing I noticed.. you're very enthusiastic about that everything should happen in exactly the correct order, and not even +/- .2 seconds deviation is in order. We're looking at around 16.000 transactions a second - that's 0.0625 ms pr transaction, or about 1/1000 of a regular internet roundtrip (50 ms is very common for DSL and Cable connections), so the of incoming requests will arrive in quite random order, within about 1000 requests .. make sure that doesn't break your business-model.