추천중입니다.
닫기 블로그로 보내기


설정된 블로그가 없습니다.

블로그 설정하기

슬라이드를 블로그에 보내는 중입니다.
루비가 얼랭에 빠진 날
1
112532
thinkr 2008.06.30 12:31:16
제6회 루비세미나 발표자료
마가린 바르기bookmarkr.netmetagsWzd.com네이버에 북마크하기다음에 북마크하기HanRSS에 북마크하기이올린에 북마크하기Pumfit에 글 올리기News2.0에 투고하기del.icio.us에 북마크하기
URL Copy_btn
EMBED Copy_btn
작성자가 등록한 다른 큐
    댓글을 작성하기 위해서는 먼저 로그인 하셔야 합니다.
    현재 댓글의 수는 2 개 입니다.
    deepblue
    deepblue
    thinkr님 발표자료는 항상 알차고~ 도움이 많이 됩니다. 특히나 이번 RADAR 구현은 정말 재밌었어요. 새로운 가능성을 보여준 것 같습니다! (2008-06-30 13:25:58 에 작성)
    chang
    chang
    deepblue님 말처럼 알찬 세션이었어요. Erlang - 특이한 녀석 같아요. (2008-06-30 15:23:46 에 작성)
    Page 0: Page 1: 루비가 얼랭에 빠진 날 http://thinkr.egloos.com sjoonk@gmail.com 제6회 루비세미나 (2008.6.28) Page 2: Concurrency-oriented Programming Page 3: How Erlang programs work? • 많은 프로세스들로 구성 – 운영체제 독립적인 경량(light-weight) 프로세스 – 유일한 식별자(Pid) – 많은 프로세스를 동시 처리(100,000개 이상) • 프로세스들 간에 서로 메시지를 주고 받음 – 비동기적 메시지 젂달 메커니즘 • 프로세스는 서로 연결(link)될 수 있음 – 연결된 프로세스가 죽으면 다른 프로세스가 통보받음 – 수퍼바이저/워커 모델 구성 3 Page 4: A Stateless Server Process -module(demo2). -compile(export_all). run() -> Pid = spawn(fun echo/0), Pid ! {self(), hello, 42}, receive {Pid, reply, 42} -> Pid ! stop end. echo() -> receive {From, hello, Val} -> From ! {self(), reply, Val}, echo(); % loop! stop -> io:format("Done!~n", []), ok end. Client P1 {P1, hello, 42} {P2, reply, 42} stop P2 Server 4 Page 5: Benefits of COP • 성능(Performance) – 분산 병렬 처리 – Multi-core Support • 가용성(Reliability) – 무정지(fault-tolerent) – Hot code swapping • 확장성(Scalability) 5 Page 6: generic_server OTP gen_server 비헤비어 6 Page 7: Apache vs. Yaws 7 * http://www.sics.se/~joe/apachevsyaws.html Page 8: REpresentational State Transfer Page 9: RESTful URL (Rails) • • • • • • • GET /posts GET /posts/1 GET /posts/new GET /posts/1/edit POST /posts PUT /posts/1 DELETE /posts/1 index show new edit create update destroy 9 Page 10: respond_to :wow! # POST /posts # POST /posts.xml def create @post = Post.new(params[:post]) respond_to do |format| if @post.save flash[:notice] = 'Post was successfully created.' format.html { redirect_to(@post) } format.xml { render :xml => @post, :status => :created, :location => @post } else format.html { render :action => "new" } format.xml { render :xml => @post.errors, :status => :unprocessable_entity } end end end 10 Page 11: GoogleTrends “ruby on rails” 1.0 1.2 resource 도입 2.0 from MVC to REST 11 Page 12: The RADAR Architecture * RESTful Application, Dumb-Ass Recipient (http://pragdave.pragprog.com/pragdave/2007/03/the_radar_archi.html) 12 Page 13: Time to Relax… Page 14: CouchDB 문서(document) 기반 데이터베이스 서버.       Aaccessible via a RESTful JSON API Views (incremental map/reduce) Schema-Free Distributed, robust architecture Written in Erlang Apache Incubating (alpha 0.8 release) 14 Page 15: SQL vs. CouchDB SQL Predefined, explicit schema Uniform tables of data Normalized. Objects spread across tables. Duplication reduced. Must know schema to read/write a complete object Dynamic queries of static schemas CouchDB Dynamic, implicit schema Collection of named documents with varying structure Denormalized. Docs usually self contained. Data often duplicated. Must know only document name Static queries of dynamic schemas * http://www.zefhemel.com/archives/2008/03/11/sittin-on-the-couchdb 15 Page 16: Document = JSON Object { "_id":"discussion_tables", "_rev":"D1C946B7", "Subject":"I like Planktion", "Author":"Rusty", "PostedDate":"2006-08-15T17:30:12-04:00", "Tags":["plankton", "baseball", "decisions"], "Body":"I decided today that I don't like baseball. I like plankton." } 16 Page 17: Some CouchDB REST APIs • Dababase API – GET /_all_dbs – PUT /database/ – DELETE /database/ 모든 DB 새 DB 생성 • Document API – – – – GET /database/doc_id POST /database/ 또는 PUT /database/doc_id PUT /database/doc_id (with ‘_rev’ property) DELETE /database/dic_id?rev=xxx /database/_view/view_name/func_name 17 • View API – GET Page 18: Accessing CouchDB with Ruby • 범용 – ActiveResource – REST Client • CouchDB 젂용 – – – – CouchObject Ruby-CouchDB ActiveCouch Couchrest 18 Page 19: DEMO Page 20: Admin Interface 20 Page 21: Ruby View 21 Page 22: Extending ARes class CouchResource < ActiveResource::Base class << self def element_path(id, prefix_options = {}, query_options = nil) "#{prefix(prefix_options)}#{collection_name}/#{id}#{query_string(query_options)}" def collection_path(prefix_options = {}, query_options = nil) "#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}" def instantiate_collection(collection, prefix_options = {}) collection = collection.fetch("rows") if collection.kind_of? Hash def instantiate_record(record, prefix_options = {}) record = record.fetch("value") if record.has_key? "value“ def find_view(view_name, func_name) find(:all, :from => "/#{element_name}/_view/#{view_name}/#{func_name}") end 22 Page 23: Mywiki Resource class Mywiki < CouchResource self.site = "http://localhost:5984" self.format = :json self.collection_name = 'mywiki' # used as a database name self.primary_key = '_id' end 23 Page 24: Console Result 24 Page 25: Finish!! 25 Page 26: