funambol - 연락처 형식 해석 최적화

1. 테스트 조건 (LoadRunner)            
(1) 테스트 동시 다발 인원: 20 명 (집합 점 이 있 음) (2) 업무 수행 에 대한 사고 시간: 1s
(3) 하나의 사무 에는 네 번 의 요청 이 포함 되 어 있 습 니 다. (완전한 동기 화 과정)
(4) 지속 시간: 30 분
(5) 연락처 수: 350    
(6) 하드웨어 환경 (가상 컴퓨터):
     CentOS 5 (2.6.18 - 164. el5 커 널)
     4G 메모리
     쌍 핵 CPU
                    
테스트 결과
top 서버 상태 관찰:
vcard:60%-80%
json:20%-30%
protobuf: 7% - 10% (protobuf 가 문자열 로 변 환 된 후 특수 문자 이기 때문에,
                 xml 에서 해석 할 수 없 기 때문에 base 64 의 디 코딩 을 추가 합 니 다.
                 데이터 전송 도 많이 줄어든다)
                
최적화
json 에 대해 서 는 JSONarray 의 문자열 형식 으로 전송 하면 됩 니 다.
protobuf 에 대해 서 는 자신의 proto 파일 을 정의 해 야 합 니 다. 다음 과 같 습 니 다.
// See README.txt for information and build instructions.

package com.test.pim.common;

option java_package = "com.test.pim.common";
option java_outer_classname = "ContactProtos";

message Contact {
    optional Name name = 1;
	optional Organization org = 2;
	repeated PhoneEntry phones = 3;
	repeated EmailEntry emails = 4;
	repeated WebPageEntry webpages = 5;
	repeated AddressEntry addresses = 6;
	repeated OnlineMessageEntry onlineMessages = 7;
	repeated string groups = 8;
	repeated string notes = 9;
	optional string birthday = 10;
	
	//Name Definition
	message Name {
		optional string firstName = 1;
		optional string middleName = 2;
		optional string lastName = 3;
		optional string suffix = 4;
		optional string prefix = 5;
		optional string nickName = 6;
	}
	
	//Organization Definition
	message Organization {
		optional string company = 1;
		optional string department = 2;
		optional string jobTitle = 3;
	}
	
	//Phone Definition
	message PhoneEntry {
	  enum PhoneType {
			MOBILE = 0;
			HOME = 1;
			WORK = 2;
			WORKFAX = 3;
			HOMEFAX = 4;
			OTHERFAX = 5;
			OTHER = 6;
			CAR = 7;
			ISDN = 8;
			CUSTOM = 9;
		}
	  optional string label = 1;
	  required PhoneType type = 2 [default = MOBILE]; 
	  required string value = 3;
	}
	
	//Email Definition
	message EmailEntry {
	  enum EmailType {
			HOME = 0;
			WORK = 1;
			OTHER = 2;
			CUSTOM = 3;
		}
	  optional string label = 1;
	  required EmailType type = 2 [default = HOME]; 
	  required string value = 3;
	}
	
	//WebPage Definition
	message WebPageEntry {
	  enum WebPageType {
			HOME = 0;
			BLOG = 1;
			WORK = 2;
			OTHER = 3;
			CUSTOM = 4;
		}
	  optional string label = 1;
	  required WebPageType type = 2 [default = HOME]; 
	  required string value = 3;
	}
  
	//Address Definition
	message AddressEntry {
	  enum AddressType {
			HOME = 0;
			WORK = 1;
			OTHER = 2;
			CUSTOM = 3;
		}
	  optional string label = 1;
	  required AddressType type = 2 [default = HOME]; 
	  required AddressExtend value = 3;
	}
	message AddressExtend {
		optional string street = 1;
		optional string city = 2;
		optional string state = 3;
		optional string postcode = 4;
		optional string country = 5;
	}
	
	//OnlineMessage Definition
	message OnlineMessageEntry {
	  enum OnlineMessageType {
			QQ = 0;
			MSN = 1;
			SKYPE = 2;
			GOOGLETALK = 3;
			AIM = 4;
			YAHOO = 5;
			ICQ = 6;
			JABBER = 7;
		}
	  optional string label = 1;
	  required OnlineMessageType type = 2 [default = QQ]; 
	  required string value = 3;
	}
}

데이터 구조 전송 코드:
 ContactProtos.Contact.Builder contact =
 ContactProtos.Contact.newBuilder();
 contact.setName(ContactProtos.Contact.Name.newBuilder().setLastName("testProtobuf").build());
 contact.addPhones(ContactProtos.Contact.PhoneEntry.newBuilder().setType(ContactProtos.Contact.PhoneEntry.PhoneType.HOME)
				 .setValue("425900").build());
				 contact.addPhones(ContactProtos.Contact.PhoneEntry.newBuilder().setType(ContactProtos.Contact.PhoneEntry.PhoneType.MOBILE)
				 .setValue("13163209158").build());
 byte[] encode = Base64.encode(contact.build().toByteArray());
 xml.append(new String(encode, "UTF-8"));

서버 분석 코드:
ContactProtos.Contact c = ContactProtos.Contact.parseFrom(Base64.decode(data.getData().getBytes("UTF-8")));

좋은 웹페이지 즐겨찾기