1. 14:17 28th Oct 2011

    notes: 8

    tags: tip

    Fixing Erlang checksum problem

    There is an installation problem on Erlang (R14B04) with Macport. When it tests its checksum, it produces ‘checksum error’ for opt_doc_html_R14B04.tar.gz. I googled on this and found some others reports. Weirdly, the file’s checksum was not updated in the Portfile of the package.

    It can be resolved with updating the checksum of the following into the Portfile:

    bash-3.2# openssl rmd160 < ./otp_doc_html_R14B04.tar.gz
    (stdin)= 0e44a933ae35fe95d1ecd9958c9e86ce398e259f
    bash-3.2# openssl sha1 < ./otp_doc_html_R14B04.tar.gz
    (stdin)= 86f76adee9bf953e5578d7998fda9e7dfc0d43f5

    And, then

    $ sudo port install elrang

    Plus: When a compilation fails, please add the following snippet into the ‘darwin 11’ section of the Profile.

    if {${configure.compiler} == “clang”}
    {   
       configure.compiler llvm-gcc-4.2 
    }
    configure.cflags-delete “-std=c99”

     


  2. 18:40 20th Oct 2011

    notes: 10

    tags: tip

    Speeding up Xcode using Ramdisk

    This is my 1 cent tip for speeding up building projects using Ramdisk.

    Steps

    1. Add more RAM modules to your MacBook (up to 8GB)
    2. Make a temporary ramdisk(1GB in size) using the following command:

    diskutil erasevolume HFS+ “ramdisk” `hdiutil attach -nomount ram://2097152`

    3. Now, the ramdisk is setup in /Volumes/ramdisk. Check it with ‘mount’ command.

    /dev/disk1 on /Volumes/ramdisk (hfs, local, nodev, nosuid, noowners, mounted by USER)

    4. Change the build path in Xcode: File -> Project Settings. Set ‘/Volumes/ramdisk’.

    5. All done.

    Benchmark Test: You can compare the speed of both ramdisk and HDD with a write test.

    dd if=/dev/zero of=/tmp/xxx bs=8k count=100000 (this took 1.8secs in Macbook 2.26GHz)

    dd if=/dev/zero of=/Volumes/ramdisk/xxx bs=8k count=100000 (this took 18secs in Macbook 2.26GHz)

    Notice: Unmount the ramdisk.

    hdiutil detach /dev/disk1

     


  3. Learning from Bacteria about Social Networks (Google Tech Talk) 

    Dr. Eshel Ben-Jacob

     


  4. image: download

     


  5. SSH Identity for EC2

    To connect Amazone EC2 instances with SSH, it needs to specify its identity(private key, a keypair from EC2). Explicitly, this can be done with ‘ssh -i keypair_file hostname’. To apply this in the system wide, it needs to expose the identity(key pair) file in a user’s “$HOME/.ssh”. This is very useful for a tool, pssh (parallel ssh), in which it does not support explicit way of specifying the identity file. I use pssh to make changes on multiple EC2 instances with one script from my Macbook.

    Recently, I upgraded my Macbook to Lion (GM Seed version). I found the OpenSSH’s identity doesn’t work any more. After some debugging on that, I figured out that it needs to specify the identity file with ‘config’ file. Before that, I just placed a EC2 keypair  file in “$HOME/.ssh”.

    A ‘config’ file of SSH maps a hostname and its identity file as follows:

    $HOME/.ssh/config:

    Host host1.amazon.com
    IdentityFile ~/.ssh/identity

    Host host2.amazon.com
    IdentityFile ~/.ssh/identity

    Host 1.2.3.4
    IdentityFile ~/.ssh/identity

    It needs to add the FQDN and the IP address hostname of a host seperately.
    Now, we can see that SSH refers the config file.

    debug1: Reading configuration data /Users/ghost/.ssh/config
    debug1: Applying options for xxxx.com
    debug1: Reading configuration data /etc/ssh_config
    debug1: Trying private key: /Users/
    ghost/.ssh/identity
    debug1: read PEM private key done: type RSA
    debug1: Authentication succeeded (publickey).

     


  6. On Beauty of Size

    The below pictures were obtained from my recent work. As growing in size, it is becoming an art. This is similar in nature. The beauty of nature comes from its size and its unpredictable outcome.

     


  7. image: download

    At last, my MIDI keyboard met the iPad2. Lovely Lovely.

    At last, my MIDI keyboard met the iPad2. Lovely Lovely.

     


  8. Emailing NETGAR logs to Gmail

    집에 설치되어 있는 넷기어 유무선 라우터가 최근 iPhone과 iPad의 접속이 매끄럽지 못하고 접속을 튕겨내는 등의 작동이 이상해서 라우터의 로그를 메일로 받아볼 필요가 생겼다. 넷기어 라우터 셋팅에 SMTP서버와 사용자 ID를 설정하면 주기적으로 메일을 받아 볼 수 있는 기능이 있는데 SSL/TLS는 지원하지 않기 때문에 직접 GMail로 메일을 받아 보기 위해서 몇가지 작업이 필요했다. 로컬네트워크에 보안기능이 없는 SMTP서버를 설치하고 다시 GMail로 퍼워드 시키는 방법도 있기는 하지만 가장 간편한 방법으로 stunnel을 택했다. stunnel은 보안기능이 구현되어 있지 않은 네트워크 종단에 암호화 통신을 제공하는 일종의 Proxy다.

    [1] 넷기어라우터 —-(plain)—> GMail (SSL/TLS)
    [2] 넷기어라우터 —-(plain)—> 로컬메일서버(SMTP)/퍼워드 —-(SSL/TLS)—-> GMail
    [3] 넷기어라우터 —-(plain)—> stunnel —-(SSL/TLS)—-> GMail


    #1. stunnel.pem 생성


    개인키와 자체인증서를 만든다. 
    openssl genrsa -out ./private.pem
    openssl req -new -x509 -key private.pem -out ./cacert.pem -days 1095
    private.pem과 cacert.pem의 바디를 stunnel.pem으로 합친다.


    #2. stunnel 셋업

    중략
    cert = /Users/xxxx/stunnel.pem
    중략
    [smtps]
    accept = 25 
    connect = smtp.gmail.com:465

    #3. stunnel 실행

    sudo stunnel ./stunnel.conf 



     


  9. My Kinect View

     


  10. HandlerSocket for MySQL

    MySQL을 NoSQL로 변신 시켜주는 참한 물건이 나왔다. 나온지 몇 개월 됐다. 현재 추진하고 있는 솔루션에 memcached나 redis를 메모리 캐쉬 서버로 앞에 두고 영성속을 위해 데이터베이스로 MySQL를 쓰려던 참이었는데 시기적절하게 좋은 물건을 만난것 같다. DeNA라는 일본의 소셜 게임회사에서 서비스용으로 현업에 사용하고 있기 때문에 일단은 검증은 되었다고 봐도 무난하다. MongoDB나 CouchDB도 쓰이고 있는 판인데 MySQL은 더 신뢰가 간다. MySQL를 KeyValue 스토리지로 사용하는 트릭도 있었기는 하지만 이번엔 제대로 나온듯 하다. 버클리DB나 Sqlite3를 DB엔진으로 두는 KeyValue스토리지도 있기는 하지만 동시성 제어 등에서 약간은 불안한 감이 없지는 않았다.

    HandlerSocket의 이야기는 이렇다. MySQL에 대해 리눅스에서 OS레벨의 프로파일링(oProfile)을 해봤더니 대부분의 오버헤드는 SQL을 파싱하고 처리하는데서 발생하고 InnoDB를 접근하는 시간은 그리 길지 않다는 것이 개발의 동기란다. 그래서 직접 InnoDB에 접근할 수 있는 통로를 HandlerSocket라는 플러그인을 만들어 뚫었다. 모든 시스템이 그렇듯 가벼우면 가벼울 수록 성능은 좋기 마련이다. HandlerSocket은 MySQL같이 SQL을 처리하는 레이어와 실제 데이터베이스 인덱싱 엔진(e.g. InnoDB)이 분리되어 있기 때문에 가능한 일인지도 모른다. HandlerSocket은 MySQL의 플러그인으로 만들어졌기 때문에 하나의 테이블에 대해 SQL과 NoSQL로 동시에 접근 할 수 있어 아주 매력적이다. 복잡한 쿼리는 SQL로 소화하고 PRIMARY로 빨리 접근하는 get/put의 경우 HandlerSocket으로 통하면 된다.

    벤치마킹 결과 초당 75만 qps를 소화해 낸다. 같은 하드웨어에서 memcached는 22만 qps의 성능이 나왔다. (벤치마킹한 하드웨어 스펙은 아래 링크를 참고.) HandlerSocket으로 접근할 경우 PRIMARY가 되는 필드가 키가 된다. 기본적으로 9998포트(읽기전용), 9999포트(쓰기전용)를 사용하고 내부적으로 16개의 쓰레드를 사용한다. Disk I/O 바운드의 데이터베이스 보다 메모리에 데이터를 다 올릴 수 있는 데이터베이스에 더 유용하다.

    HandlerSocket은 기본적으로 C++과 Perl 클라이언트 라이브러리를 제공한다. 파이썬 바인딩으로 pyhs(python-handler-socket)가 있다.

    Percona-Server 5.1.34 r12.5 바이너리 배포판에 함께 컴파일되어 내장되어 있기 때문에 쉽게 테스트 해 볼 수 있다. 100만건 테스트를 실시할 예정인데 memcached, redis와 비교해 성능이 어떤지 궁금해 진다.

    참고자료