Two computers : One is a memcached server , the other one is to write the logical server.
logical server only logical operations , memcached caching user data when logical server requires data obtained from memcached above and temporarily cached locally , modifying user data , and then save it to the memcached server , and empty the local the data.
so there will be a question of logical servers memcached multiple threads simultaneously modify a user on the data, there will be concurrent problems that may lead to memcached above data is overwritten.
My idea is to give the user the logical server side data plus a lock, a user to modify data, first get the user's lock , and then take the memcached access to the data above , and then modify the data, and then Save to memcached, and then release the lock .
feel this way, the efficiency may be lower , I do not know there is no better way to achieve this , please master guiding !
------ Solution ---------------------------------------- ----
the user data according to user name hash% the number of threads , each thread processing the corresponding user data
------ For reference only ----------- ----------------------------
added: logical server is using java .
------ For reference only -------------------------------------- -
I wish to address is the data synchronization problems ah
------ For reference only ------------------------ ---------------
there are different types of threads may modify the same data
没有评论:
发表评论