Hi All Thanks for pay attention to my mail, I had meet a problem, can you please give me some advise or suggestion.
my problem as bellow : 1. There was many content( docs, picture, topic ...) in my web applications. 2. Each content has a accessCount value, work for record how many times the content being viewed. we store the accessCount value in Cassandra. 3. Every times user view the content, the accessCount will increase 1. Every increase, I need to do 3 steps, first read current value, then increase it, at last store it back to Cassandra. 4. User access was happed on many different webservers , so If 2 user access same content at same times, then accessCount maybe will incorrect, becuase I maybe lost one access count. As I know, Cassandra have not inc/dec method current, I have to design some way to make accessCount correct as bellow, it not very well , so please let me know if you has more better way, thanks. Way 1. Got help from memcached, becuase memcached has inc/dec/CAP method, so I can using memcached to maintains the accessCount value, and have a backend cronjob to sync the value to cassandra with fixed time period ( eg: sync it every 5s ). This way can make things easy, but have risk if the memcached server was down, will lost 5s counts, another risk is, the backend cronjob was a single failuer point . Way 2. Create a ColumnFamily as access queue, every times, user access action will being pushed into this queue with timeUUID, a backend job will batch read all access action, count it with inmemory loop. After got the result, then store it back to Cassandra. This way was all based on Cassandra, the backend job still was a single failuer point. Way 3. Like RDBMS's optimistic lock, if remove operation can return the number of column being removed or update , then bellow code should can work: while(true){ int count = readAccessCount( contentID ) ; // get the value, if the value not exist, will loop until to get it if( deleteOldAccessCount( contentID, count ) != 1 ){ // remove old count, if it already removed, then conflicte happend, will get the value again. writeAccessCount( ++count ); // after remove old value, insert new value break ; } } but dur to my test, even the remove target not exist, remove operation still sucess have not any return. Is there some work arround to make optimistic lock? I think somebody shold meet same problem as me, can you tell us your solutions? Thanks -Santal