memcached and distribution or assignment

I have been using Memcached in a lot of different type of caching solutions for web services and thought of sharing some basic facts,

  1. Memcached servers are just very efficient key value storage providing APIs to get and set values over the network.
  2. Client makes the solution distributed. The client has the logic to select or choose the destination host for get or set operation using consistent hashing.
  3. The memcached client library supports a number of different distribution algorithms that are used in multi-server configurations. Please read the protocol.
  4.  The cache key is used in the consistent hashing to determine distrubution. The same server is selected during both set and get operations. The algorithms are Ketama and Wheel in code.
  5. following diagram is for simplicity in understanding the process.

Untitled Diagram

In the next post, I will show how to use Guava and Memcached together to implement a multi layered caching solution.

Advertisements

0 1 knapsack Java Code

     /**
     *
     * @param w weight for items
     * @param v values for items
     * @param i number of items
     * @param W the max weight
     * @return what knapsack/0-1 should return
     */
    static int knapsack(int[]w, int []v, int i, int W){
        if(i < 0) return 0;         if(w[i] > W){
            return knapsack(w,v, i-1, W);
        }else {
            return Math.max(knapsack(w,v, i-1, W), knapsack(w,v, i-1, W-w[i])+ v[i] );
        }
    }

2.11 years without a post

I like writing about what I am thinking but somehow I have stopped for past 2.11 years after I changed my job. I did not do well though to put an excuse for not writing so I am going to write about many interesting things I found along the way and about my new research on dimensions “From 3 to 2 or 3 to 4

Writing your blog posts in Assamese

Ok, There is no direct support to write blog posts (atleast in wordpress or blogspot) in assamese but you can write with help of some unicode editors. One important thing to remember that your browser need to support unicode formats. Well, IE 6+ and Mozilla Firefox supports unicode character formats.

Steps:

In assamese , “O mor apunar desh”…

অ’ মোর আপোনার দেশ,

অ’ মোর চিকুনি দেশ,

এনে খন সুব্ লা , এনে খন সুফলা, এনে খন মরমর দেশ।

এনে খন সুব্ লা , এনে খন সুফলা, এনে খন মরমর দেশ।

…..