memcached info

Introduction:
http://blog.xdite.net/?p=1029

http://ihower.idv.tw/blog/archives/1768

 

Internal implementation:
http://tech.idv2.com/2008/07/10/memcached-001/

 

update data in DB:
If we delete data in memcached when we update data in DB, it will cause “cache stampedes”. It is if there are many clients find out the entry isn’t in memcached at the same time, all of they will try to query from DB, then it will cause performance issue. So we need to create a lock in memcached, every client will try to check whether the lock is exist. If it is not exist, it can query and delete it after finish, other clients will wait a period time to wait cache.

 

data fragment and for each item:
We need to make experienment for choosing cache data!

Now for this simple application, coding something like this is simply overkill, so let’s look at a more practical example: a photo sharing site that contains lists of photographs with links to detail pages.
Many such sites display paged lists, so 100 pictures in a list might be displayed as thumbnails with basic information, ten per page. Based on all of the coding we’ve done, it might seem reasonable to go get a list of one page of data from the database, cache the resulting list and then get the second page and cache that list and so on. But there’s another way to handle that.

Start by getting the list of all 100 items that make up the list and cache that. Build the paged lists from that information, rather than going back to the database for every page. Now the same list serves someone who only wants to see 5 items per page as well as some-one who wants to see 20, which is better than having to query the
database 20 times for one person and another 5 times for the other, when all we’re doing is showing the same data paged differently.

The most important thing to remember is that this is not an all-or-nothing approach. You may have data that lends itself to stor-ing nothing except lists of pointers, and then store the individual data items separately. But you might just as easily have data where it makes more sense to store lists that contain data. This is one of those things you need to experiment with and see which makes more sense for your application.

From Using Memcached

Advance:
http://blog.gslin.org/archives/2008/12/13/1884/

http://highscalability.com/blog/2009/10/26/facebooks-memcached-multiget-hole-more-machines-more-capacit.html

 

multiget hole:
Adding new memcached server didn’t help when it’s CPU bound. What it can happens is when you add more servers is that the number of requests is not reduced, only the number of keys in each request is reduced.
Ex: If you have send 50 requests to 2 memcached servers, and each request use multi_get to get 100 entries. So each memcached server will contain 50 entries. After you add one memcached server, the requests are still 50, but only each memcached contain 33 entries. Requests are not reduced. As a result we’ve done absolutely nothing to reduce the usage of our scarce resource which is CPU!
http://highscalability.com/blog/2009/10/26/facebooks-memcached-multiget-hole-more-machines-more-capacit.html

[]

Now I just don’t have that mood for birthday…I just don’t know what’s the birthday meaning for me now. As a result, I don’t expect a birthday party or something. But I will remember whatever you do for me, thanks forever

Perception change the solution!

今天看到一個有趣的演講, 是這樣子的, 現在想要縮短倫敦到巴黎的時間, 這時候工程師就開始想solution, 最後終於想出來了一個好方法, 這個solution花了60億, 也就是再蓋一條新的鐵路, 縮短了40分鐘的車程, 但是其實我們可以往另一個方向去想,  我們用30億的錢把全世界最頂尖的model都請來站在鐵軌上, 這樣我相信大家還會要求把列車速度降下來呢! The same problem, but different solution!

還有一個故事, 有一個國王想要他的子民能夠推廣多種馬鈴薯, 但是那個時候沒有人想種這種看起來髒髒的作物, 但是他又不能強迫大家種, 也不能把不種的人處決掉, 所以他就散佈假消息出去, 說馬鈴薯是貴族愛用的食物, 然後再把如何栽種的方法寫下來, 再想辦法讓別人把方法偷走~ 果不其然, 後來大家就開始種植馬鈴薯!

其實很多時候很多東西都只是認知上的差異, 這也是為什麼安慰劑(placebo)的存在, 如果我們能給予舊的東西新的象徵, 也會有不一樣的結果~

如果不告訴你喝的酒很貴, 你真的分的出來嗎??

曾經再書上看過一個例子, 你覺得一瓶水應該賣多少錢呢??

在問一下, 你覺得一瓶水對於一個在沙漠的人, 又應該賣多少錢呢?

怎麼樣充分利用你所有的東西, 這可真是一門學問阿~

[work] working about 3 months

不知不覺中, 我已經工作三個月了, 三個月說長不長說短不短, 或許也是該來回顧一下自己過去三個月做了甚麼!

其實大部分我的朋友都會覺得我實在是過太爽XD, 其實我們公司很自由, 完全是讓你自己操控(你看PDD不是忙的甚麼鬼似的)~ , 所以過太爽是因為我在還沒有完全定下心工作, 希望慢慢的我可以把自己的心態調整好, 至少上班時間不要打混…(OS: 不然就對不起我的老闆了XD)

我很慶幸就目前為止, 我當初的選擇似乎沒有錯?!

過去三個月, 雖然沒有像camel隨便就3,4千行的python code, 但是還是有寫了一些東西~

python:
寫了個簡單的server, about 500行, 加上extend c lib加速, 還有寫了類似壓力測試的程式來測試, 學了一點點unit test

erlang:
這部分不得不推, 在台灣大概肯讓我自己玩這個東西的公司應該是沒有吧XD, 花了點時間把O”Relly的Erlang Programming翻完, 而且我最近終於開始動工, 目前是寫了一千多行(加上測試), 還trace了網路上的一個light http server source code, 學會了別人是怎麼寫類似的東西! 這些東西書上都不會提到…

twiki:
幫公司架了一個wiki, 現在大家好像比較有把東西往那邊丟, 不錯不錯!

git:
雖然公司現在全面使用SVN, 但是我自己無聊架了一個git, 翻了前幾章的pro git這本電子書, 了解了一點distribute version control system~

還有大概了解公司某部分最核心的source code~

接下來要把我之前自己寫的東西串起來加上開始測試別人的東西, 還有另一個案子過陣子應該也要動工@@”

不過不知道為什麼, 雖然說還是蠻喜歡寫程式的, 但是好像沒有高中那種衝勁, 有點甚麼都可以的感覺, 希望能慢慢找到自己最愛的領域, 好好鑽研~

不過小公司還是有點壞處, 就是沒有像PDD他們那樣多采多姿的社團生活>”<

p.s 耶?! 才剛說不要偷懶, 結果我就在上班時間打了這篇文章XDD

[movie] P.S 我愛你

這真是一部好看的電影!! 強力推薦

老實說看到一開始, 讓我想起了一些事情, 我完全掉進回憶的漩渦中…至今我還沒有走出來, 所以我一直都是逃避, 不想去想它, 沒什麼勇氣

因為我越想就越想哭, 很多話都還沒說呢…

什麼時候我才有勇氣面對呢

This is a test!

Just a test!!!

[Git] setting up environment

Ubuntu install Git

$sudo apt-get install git-core git-buildpackage

Environment setting

首先要先選定一台遠端的server A, 在server上面新增一個git user (ex: git)

$sudo adduser git

接著就

$ssh git@REMOTE_SERVER (server A)

#once login
$mkdir example.git
$cd example.git
$git –bare init

接著回到自己的local client

$mkdir example
$git init
$touch xx
$git add xx
$git commit -m ‘first commit’
$git remote add origin git@REMOTE_SERVER:example.git
$git push origin master

之後在local一樣git add, git commit, git push origin master

如果想要check out出來exist project

$git clone git@192.168.1.67:xxx.git

就可以了!

Reference: http://progit.org/book/ch4-4.html

2009/07/10~07/12 夢幻露營

熱血團重啟, 這次是參加菁芬老師的傳說中夢幻營地, 不過因為見到了久違的家齊, 吃到了美味的燒烤!!! (真的烤的很好吃!!!)

經過了前一段時間對事物的默然, 最近才慢慢從沉悶的生活中走出來, 我果然慢慢不太習慣過著太單調的生活了, 看著一群high咖就覺得很有趣, 而這次又多認識了兩位新同學XD

菁芬老師的生日趴, 熱情的Q爸, Q媽讓我們吃豐盛的早餐 (OS: 重新體驗成功嶺新訓之睡覺?!),   牧場的蚊子大戰, 媝姐的畫圖遊戲, 雖然最後我沒有參加加碼行程, 但是見識到了熱血跟隨興的一面, 感覺大家都是有趣的人, 相信大家一定都會心想事成~

感謝讓我這阿宅過了不太一樣的週末

台中燒烤 -> 彰化和美過夜 –> 南投埔里酒廠 –> 顏式牧場過夜 –> 紙教堂 –> 日月潭 –> 台中市區 –> home
相簿

[Unix] Debug method

No matter what kind of language you use, this method can provide a way to debug. At first you need to set run the command “ulimit -c unlimited”. Then just run your program, onece it segmentation fault it will generate core-dump file. And then you can run gdb to start debug!!!

gdb [options] [executable-file [core-file or process-id]]
ex:
gdb python core

[bike] 2009/07/05 三峽之旅

久違了的腳踏車之行阿~~~

今天從南港—->公館—–>新店溪8.5km—->大漢溪—–>台三線—->三峽土城

total大約70km

雖然很熱, 但是偶而騎還是不錯, 不過我還是比較喜歡騎山路那種讓你心跳快暴掉的感覺, 上坡很累, 但是下坡很爽很有快感XDD