'Google'에 해당되는 글 3건

  1. 2011.08.03 구글 프로토콜 버퍼 (Google Protocl Buffer)
  2. 2008.05.27 Google Sites
  3. 2008.05.14 Map Reduce 2


PPT 작성 자료








* 배경
RPC와 쉽게 연동, Not RPC
하나의 개념으로 다양한 언어에서 쓸 수 있게 구글에서 다양한 언어별로 개발 하다 보니. 통신을 위한 단일 표준이 필요

  proto 파일 -> proto 컴파일러 -> 여러 언어로 변환 (java, python, c++)

Not socket
구글 에서 2008년 7월 발표
이슈 제시
- XML 문제
- Parsing, serialization  (debugging)
- Portable : IDL처럼 사용
- Heavy Optimization
- Language 지원
짧은 데이터의 송수신 용도/긴 데이터 송수신이 목표가 아님

* XML 보다 좋은 점
Simple
3~10배 작음
20~100배 속도 빠름
모호하지 않음
바로 프로그램에 사용하기 쉬움

* 레퍼런스
Protocol Buffers: A new open source release
    http://www.youtube.com/watch?v=K-e8DDRwVUg

Home Page
   http://code.google.com/p/protobuf/

개발자 가이드
   http://code.google.com/intl/ko-KR/apis/protocolbuffers/docs/overview.html

Protocol Buffer Language Guide
    http://code.google.com/intl/ko-KR/apis/protocolbuffers/docs/proto.html

API
    http://code.google.com/intl/ko-KR/apis/protocolbuffers/docs/reference/java/index.html

PB 포맷
    http://wiki.openstreetmap.org/wiki/PBF_Format

비슷한 솔루션과 비교
    https://github.com/eishay/jvm-serializers/wiki


* 활용
구글
- 원래 index server request/response protocol로 사용했었음
- 48,162 different message types
- 12,183 .proto files
다양한 회사
국내/외 게임 회사의 통신


* 장점
쓰기 편함
Stub 코드 자동 생성
- 통신에서 가져야 할 보편적 특성을 다 추가
- Serializing, Parsing 지원
코드 일치
- 클라이언트/서버 코드 동일
IDL 형태로 정의가 단순
- Portable
- 클래스 또는 struct 디자인
언어 지원
java, c++, python
3rd party lib (많은 언어 지원. http://code.google.com/p/protobuf/wiki/ThirdPartyAddOns#RPC_Implementations)
배우기 쉬움
이클립스 플러그인 존재
Lite 버전 개발 가능
Good Document
BSD license
언어마다 특화되고 쓰기 편한 특징을 제공

* 단점
Output이 binary만 존재
- PB의 Reflection을 이용해서 json으로 전달 가능
Map, set 지원 없음


* 개발환경 구성
Download proto compiler in google code
- http://code.google.com/p/protobuf/downloads/list

(Option) eclipse plugin
- http://protoclipse.googlecode.com/svn/trunk/site/


* proto 파일


// text.txt
package test;

message Request {
  required string command = 1;
  optional string param = 2;
}


 



/cygdrive/c/protocolbuffer
$ ./protoc.exe test.txt --java_out=.



Test폴더 생기고 TestTxt.java 생성됨
(17KB, Protocol buffer 내부 클래스 사용)

// c++ 로 하면
test.txt.pb.cc (12K)
test.txt.pb.h (8K)

// python으로 하면,
test/txt_pb2.py (2K)

* 생성된 자바 코드
Descriptor 지원
- internal_static_test_Request_descriptor
Reflection 지원
- Message / Message.Builder interfaces.
- Json 처럼 프로토콜로 변경 가능 (ajax 가능)
메시지 수정시 하위 호환 보장, 새로운 메시지로 변경되면 기존 코드에 대한 필드만 처리
파일이름을 디폴트로 해서 소스를 생성하지만, 내가 원하는 클래지 이름과 클래스 이름의 개별 지정이 가능
- option java_package = "com.example.foo.bar";
- option java_outer_classname = “ProtocolData";
PB의 Enum은 java의 enum으로 변경


* 크기 제한
디폴트로 크기 제한 : 64 MB
속도를 최적화 또는 악의를 가진 사용자로부터 보호하기 위해서 크기를 제한할 수 있음
- CodedInputStream/CodedOutputStream (ZeroCopyInputStream/ZeroCopyOutputStream ) 
   SetTotalBytesLimit 메소드

* proto 파일 생성시 유의할 점
package 선언
클래스 파일 이름
운영을 위한 파일명 .proto
message 등록
- Protocol buffer language guide
Protoc.exe(컴파일러)에 의해 만들어진 java, python, c++ 코드는 고치지 말아야 한다.(immutable)
protoc에서 컴파일 되면, 자동으로 accessor가 붙는다.
- get/set/has…

* message 설명
package
Type
- Bool, int32, uint32, float, double, string, bytes,  ….
- Enum
Nested type
Default value
importing
Modifier
- required : 반드시 사용해야 할 필드. 미초기화된 상태 미초기화된 메시지를 빌드하면 RuntimeException, 초기화되지 않은 메시지를 파싱하면서 에러나면 IOException발생
- optional : option의 개념
     hasXXX() 로 확인
- repeated : 0을 포함하는 개수를 계속 넣을 수 있음
     자바에서는 List객체로 구현됨


* 필드에 번호를 반드시 주는 이유
번호를 주지 않으면 protoc 에러 발생
Write/Read 할 때, serialization 순서를 주기 위함
필드 정보가 set되었는지 쉽게 알기 위함(내부적으로 bit 연산함)

* Versioning 정보가 없는 이유
새로운 필드를 언제든지 추가 될 수 있음
모든 정보를 볼 필요 없이 필요한 정보만 파싱할 수 있도록 함
But, java는 기본으로 존재하지 않지만, c++ 은 존재한다. 링킹 이슈. (GOOGLE_PROTOBUF_VERIFY_VERSION 매크로)
Incompatible한 버전 때문에 문제가 없도록 해야 함


* 데모 1

// text.txt
package test;

message Request {
  required string command = 1;
  optional string param = 2;
}


 



generated 자바 코드 로 컴파일


<Writer.java>

package com.example.test;

import java.io.FileOutputStream;
import test.Test.Request;

public class Writer {
    public static void main(String[] args) throws Exception {
        Request request = Request.newBuilder()
                                       .setCommand("commit")
                                       .setParam("every files")
                                       .build();
        FileOutputStream output = new FileOutputStream("r.os");
        request.writeTo(output);
        output.close();
    }
}




<Reader.java>
package com.example.test;

import java.io.FileInputStream;
import test.Test.Request;

public class Reader {
    public static void main(String[] args) throws Exception {
        Request request = Request.parseFrom(new FileInputStream("r.os"));
        System.out.println("command : " + request.getCommand());
        if (request.hasParam()) {
            System.out.println("params : " + request.getParam());
        }
    }
}



 

<실행결과>
command : commit
params : every files


* 데모 2


<writer.cpp>

#include <iostream>
#include <fstream>
#include <string>
#include "test.pb.h"

using namespace std;

int main(int argc, char* argv[]) {
 Request request;
   request.set_command("init");
 request.set_param("0");

           fstream out("streams", ios::out | ios::binary | ios::trunc);
 request.SerializeToOstream(&out);
 out.close();

 return 1;
}



 



<reader.cpp>
#include <iostream>
#include <fstream>
#include <string>
#include "test.pb.h"

using namespace std;

int main(int argc, char* argv[]) {
    Request request;
    fstream in(“streams", ios::in | ios::binary); 
    if (!request.ParseFromIstream(&in)) { 
          cerr << "Failed to parse streams." << endl; 
          exit(1); 
    } 
    cout << “command: " << request.command() << endl; 
    if (request.has_param()) { 
         cout << “param: " << request.param() << endl; 
    }
}

 

* 데모 3


package tutorial;

option java_package = "com.example.tutorial";
option java_outer_classname = "AddressBookProtos";

message Person {
  required string name = 1;
  required int32 id = 2;
  optional string email = 3;

  enum PhoneType {
    MOBILE = 0;
    HOME = 1;
    WORK = 2;
  }

  message PhoneNumber {
    required string number = 1;
    optional PhoneType type = 2 [default = HOME];
  }

  repeated PhoneNumber phone = 4;
}

message AddressBook {
  repeated Person person = 1;
}


* 속도
용량이 작다고 가정했을 때, 상당히 빠르게 동작하는 솔루션임
추후 Thrift와 Avro와 비교 테스트 예정

Posted by '김용환'
,

Google Sites

Trend 2008. 5. 27. 00:42

드디어 구글 Sites가 정식으로 공표했다.

쉽게 말해서 홈페이지 쉽게 만들어주는 것이랏다.

 

 

Google Sites is the easiest way to make information accessible to people who need quick, up-to-date access. People can work together on a Site to add file attachments, information from other Google applications (like Google Docs, Google Calendar, YouTube and Picasa), and new free-form content. Creating a site together is as easy as editing a document, and you always control who has access, whether it's just yourself, your team, or your whole organization. You can even publish Sites to the world. The Google Sites web application is accessible from any internet connected computer.

 

 

출처

http://www.google.com/a/help/intl/en/users/sites.html

 

 

 

 

 

Google Sites makes creating and sharing a group website easy.

  • Single-click page creation
  • No HTML required
  • Customizable look and feel
  • Settings for accessing and sharing information
  • And it's free!

샘플은 다음과 같다.

 

머 그다지 신선한 내용은 홈페이지에서 보이지 않는다.

 

자 구글 싸이트의 홈페이지 제작 동영상을 유부트를 통해서 보자.

기존에 있었던 나모가 웹버젼으로 나왔다는 것 외엔 크게 느껴지는 감흥(?)이 없었다. 이미 상용버젼에서는 사용되는 웹 버젼 웹 에디터정도로 느껴지는 것은 무엇일까?

 

너무 템플릿중심의 에디터라 크게 감동을 받지 못한 터라.. 비즈니스 모델이 궁금해졌다.

어떻게 돈벌려고 이런 구글 site를 내어놓을까?

 

구글 Apps Premier Edtion을 찾아보았다.

 

 

Google Apps Premier Edition also includes:

Gmail: 25 GB email storage per account and powerful spam filtering

Google Calendar: Shareable calendars

Google Docs: Real-time mult-person docs editing

Google Talk: Free voice calls and text messaging

자세한 내용은 여기서 참조

http://www.google.com/a/help/intl/en/business/applications.html

 

30일동안 트라이를 해볼 수 있도록 하고, 구글에서 발표한 멋진 서비스들을 엄청나게 사용할 수 있다라는 장점이 있다.

특히. 이 구글은 클라이딩 컴퓨팅 개념을 서비스에 추가한 흔적이 보였다.

 

바로 Salesforce.com이다.

이 salesforce.com은 플랫폼을 service로 제공해주는 플랫폼 서비스 회사이다. 즉 웹을 이용해서 전자 상거래를 위한 플랫폼 기반을 제공하는 우리나라의 웹 호스팅 회사가 비슷하다.

 

이 회사는 구글과 협력하여 적당한 서비스를 할 수 있도록 제공하였다.

즉 장사하고 싶지? 그럴려면 이멜도 필요하징.. 문서만드는 것도 필요하징. 홈페이지도 만들어야지..

그럴려면. 이거랑 이거랑 조합해서 써.. 나머지는 우리가 할께..

장사가 잘되면, 큰 용량이 필요하지?그럴떄 돈내고 써~~

 

 

Salesforce and Gmail

E-mail and CRM—Joined Together. See your productivity soar when you use Gmail for business and send messages to contacts from inside Salesforce or log e-mails in Salesforce from Gmail.
Learn More 

 

Salesforce and Google Talk

Instant Messaging Inside Salesforce. Instantly communicate with colleagues right from Salesforce—> during sales or customer services calls, in discussions with partners, or when reviewing CRM data in Salesforce.
Learn More

 

Salesforce and Google Docs

Real-Time Document Collaboration. Share documents with your colleagues, partners, and customers so that everyone can work together in real time—no more e-mailing attachments or worrying about different versions floating around.
Learn More

 

Salesforce and Google Calendar

Multiple Calendars Managed Together. Manage your various work activities plus your personal and outside calendars all in one easy calendar interface with the checkbox simplicity and drag-and-drop convenience you would expect from Web 2.0.
Learn More

 

Salesforce and Google Start Page

Everything That Matters—in a Single Glance. Start your day with a customized, all-in one view of everything that matters to your business.
Learn More

 

 

즉, 개인 사용자로부터 돈 받는 수익모델이 아닌, 기업가에게 제공해주는 툴을 이용해서 어느정도 용량이 부족하거나, 용량이 필요하는 시점에서 돈을 받고 서비스를 진행시켜줌으로서, 구글과 salesforce.com은 돈은 벌 수 있을 것이다.

 

누이 좋고 매부 좋은 모델이 아닌가?

 

또한 구글은 구글 Site에서 여러 클라우딩 서비스들을 짬뽕시켜 줌으로서 강력한 허브의 힘을 가질 수 잇는 장점도 있을 것이고..

 

점차 일반 개인들도 이러한 홈페이지를 통해서 언제가는 수익성을 가지는 시점에서는 자사의 서비스를 돈을 주고 서비스하는 시대가 올 것을 판단하고, 투자하는 마음으로 오픈한게 아닐까??

 

앞으로 이 구글 싸이트를 통해서 많고 좋은 서비스들이 나오고. 선한 영향력이 발휘되면 좋겠다.

Posted by '김용환'
,

Map Reduce

Architecture 2008. 5. 14. 21:25

구글의 검색 엔진의 기본 핵심이다.

 

functional langaue인 lisp에 영향을 받은것으로 보이며, 간단 명료하게 병렬 배취기능형태로 제공된 것으로 보인다.

 

홈페이지 및 출처는 다음과 같다.

 

http://labs.google.com/papers/mapreduce.html

 

 MapReduce: Simplified Data Processing on Large Clusters
Jeffrey Dean and Sanjay Ghemawat

 

 

아주 간단한 input/output 프로그래밍 api를 가지고 있다.

 

 map (in_key, in_value) -> list(out_key, intermediate_value)

reduce (out_key, list(intermediate_value)) -> list(out_value)

 

이런식으로 구글 소스 트리에 사용되는데. 계속 사용되고 있다..

 

 

 

실행에 대한 개념이다.  중간값이 만들어지고, 그룹된 Key에 의해서 그룹되어서 결과를 나오게 한다.

 

 

 

 

 

 

이를 이용해서 병렬처리는 다음과 하게 되어 있다.

 

 

좀더 쉽게 설명되면 다음과 같다. (출처 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/JCvs/Search/Document/ManReduce?action=download&value=mapreduce.png)


 

 

자연스럽게 시간에 대한 pipe개념도 추가되어 있다.

 

또한 재실행하는 문제에 대한 문제까지도 고려하고 있다.

 

기본 데이터가 없어서 성능쪽은 비교대상이 없기 때문에 쉽게 말하기는 어려운 것 같다.

 

관련한 논문은 다음과 같다.

  • Programming model inspired by functional language primitives
  • Partitioning/shuffling similar to many large-scale sorting systems
    • NOW-Sort ['97]
  • Re-execution for fault tolerance
    • BAD-FS ['04] and TACC ['97]
  • Locality optimization has parallels with Active Disks/Diamond work
    • Active Disks ['01], Diamond ['04]
  • Backup tasks similar to Eager Scheduling in Charlotte system
    • Charlotte ['96]
  • Dynamic load balancing solves similar problem as River's distributed queues
    • River ['99]

 

결론은 다음과 같이 내었는데..

 

 . MapReduce has proven to be a useful abstraction
  • Greatly simplifies large-scale computations at Google
  • Fun to use: focus on problem, let library deal w/ messy details
  •  

     

    추상적인 모델로서 증명되었고, 구글에서 큰 스케일의 계산을 심플화했고, 문제에 포커스를 가지도록 하고, 복잡한 것은 그냥 라이브러리에서 실행할 수 있도록 하였습니다.

     

     

    참조자료.

    http://ypshin.com/2690309

    http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/12/MapReduce

     

     

    개인적으로 병렬처리를 하는 백엔드 worker, batch 작업에 써먹을 수 있는 형태로 보인다. 간략함으로서 사용자에게 편의를 제공하는 것으로 보인다.

     

     

    Hadoop 은 바로 이 MapReduce를 구현하였다. http://hadoop.apache.org/core/

    분산 파일 시스템 Hadoop가 MapReduce 를 구현했다고 보니. 많이 놀랬다.

     

     

     

     

    자세한 것은 다음에.. ㅋ

     

    참조 자료

    http://hadoop.apache.org/core/docs/current/ Hadoop 위키 페이지

    http://freesearch.pe.kr/893 속도 테스트

     

     

    Posted by '김용환'
    ,