티스토리 툴바

Mongodb + Django 사용기..

IT 2011/11/17 20:20
Django에서 오브젝트 데이터베이스를 사용에 있어 가장 불편한 점은 join operation과 연산 operation이 아닐까 한다.
특히, 아무리 오브젝트로 잘 "관계"를 잘 만들었다 하더라도 뒷단에서 관계형 데이터로 돌아가다 보니 생각보다 성능이 나지 않는다. 설계시부터 join을 하지 않도록 만드는 것이 좋은 방법이나 로직에서 수피해 갈 수없을 때도 있다.
이를 잘 대응하기 위해서는 cache로 데이터를 잘 사용하거나 중복을 있더라도 데이터를 오브젝트에 넣는 방법이 아닐까 한다. mongodb가 오브젝트 데이터베이스가 가지고 있는 한계를 해결해주지는 않는다.
하지만 mongodb와 오브젝트 데이터베이스가 관계형 데이터베이스를 지양한다는 것에서는 보다 mongodb가 관계형 데이터베이스 보다 나을 듯 하다.
기본적으로 뒷단에서 관계형 데이터베이스를 맵핑하는 작업은 없을테니깐 말이다.
실질적으로 Mongodb를 쓰면서 가정 편한 점은 manage.py syncdb을 사용하지 않는 것이다.
개발 단계에서 스키마를 변경할 때 마다 이전 데이터를 백업하고 다시 syncdb하는 것은 거의 악몽수준이다.
syncdb 하지 않는 것만으로도 Django가 추구하는 "빠른" 개발에 도움을 준다. 또한 강력한 mongo 콘솔을 사용하여 추가 작업을 원할히 할 수 있다는 것도 좋다. 백업도 너무 쉽다.

다음은 mongodb와 sqlite3와 단순 비교이지만 속도차는 매우 심하다.
 

from brispone.models import TestDoc
s = time.time() for i in xrange(1000):
t = TestDoc(title='a', chapter=1, page=1)
t.save() ct = time.time() - s

print ct

mongodb에서는 생성시 0.354 걸리던 것이 sqlite3는 무려 174.78이다!!!.
삭제시는 0.4786 / 174.084이다. 믿을 수 없다...헉...
현재 한 두가지 문제점이 있으나 사용에 익숙하지 않기 때문에 발생할 수 있는 것이고 대체적으로 심각한 문제는 찾지 못했다.

설정

트랙백

댓글

I've never handled big data since I worked. As you know, database part is so big and crucial.

When I learned database in my university, my professors taught me integrity and non-redundancy of data based on relational database.


Have been working in a real field as a software programmer, I always worry about its performance and optimization.

However, as a system is bigger, database is much complexer. Which means I have no choice but to do join operation and make new table or view to support new functionality. It could follow a consideration about database's scalability. Relational database has weak points such as that.


Moreover, trends have changed from relational database to ORM(object-relational mapper) with new many frameworks like Django which is web framework by Python. One of disappointments of ORM is not to support full functionality of relational database and performance.


I finally tried to find new database system. As soon as I did, I realized that NoSQL is new wave for Web2.0. Mongo DB system, one of NoSQL database systems, is from 2007 and made to overcome many flaws of relational database even thought Object-oriented-database exist to solve the same problems.


Mongo DB provides simply syntax, light operations and extra new features. The most interesting thing has no schema which can offer the freedom of changing data anytime. One more thing provides system's scalability. You can backup database with 1 line command. It is awesome.


This book is perfect for beginner. Basically it is thin but gives good benefit not to lose your interesting. I read it for 5-6 hours without testing examples in it.


In terms of Django which aims to develop fast and flex, it is just the job with Mongo DB. Pymongo is a package for developer to use it with Python and mongo engine is suitable for Django.


I recommend a few things

- It helps to choose DB system http://www.odbms.org/download/Cattell.Dec10.pdf

- After installing mongo DB, you can meet this warning message "*** warning: spider monkey build without utf8 support.  consider rebuilding with utf8 support" about UTF-8. You can fix it from this site(http://wmilesn.com/2011/07/code/why-does-mongodb-fail-when-searching-non-ascii-entries-a-k-a-how-to-properly-install-mongoddb/).

http://www.youtube.com/watch?v=w5qr4sx5Vt0


설정

트랙백

댓글

최근 열린 구글 I/O 2011 이벤트 페이지(http://www.google.com/events/io/2011/#again)나 Angry bird on Chrome처럼 과거에는 어도비 플래시를 이용해서 만들 수 있었던 기술들을 표준, Open 이라는 이름과 함께 구현할 수 있게 되었다.

이것이 가능한게 된것은 HTML5와 자바스트립트 그리고 CSS3 때문이다.

(이미지 출처 :http://www.hanb.co.kr/book/look.html?isbn=978-89-7914-826-8)



하지만 비록 HTML5의 구문과 자바스트립트 문법을 적당히 숙지하고 있더라도 막상 구현해 보고자하면 어디서부터 출발해야 할지 좀처럼 잘 떠오르지 않는다. canvas를 이용해야 할 것 같은데.. 마우스 이벤트는 어떻게 받지.. 예전 자바스트립트에서 처럼해야하는지...문제는 HTML5의 새로운 구문들과 이것을 어떻게 적용해야 하는지 영 갈 길을 잡지 못하기 때문이다.

[한번에 배우는 HTML5 + 자바스크립트] 이런 사람들에게 추천할 수 있는 책이다. 처음 HTML5나 자바스크립트를 접하는 사람들에게도 별 무리없이 접근이 가능하며 자바스크립트를 잘 아는 사람들은 가벼운 마음으로 읽을 수 있는 난이도에 책이다.
책은 깨뜻한 이미지이며 다양한 색을 이용하여 편집되어 있어 책 읽기에는 좋다. 하지만 코드 부분은 좀 익숙하지 않은데 라인별 줄이 되어 있기 때문에 그러하다.

요즘 jQuery에 익숙한 개발자라면 "아 이전에 이렇게 코딩해지..." 라며 코드를 볼 것 같은데 jQuery로 포팅하는 것도 재미있을 듯..

몇가지 쉬운 게임을 만들면서 이벤트 처리, 로컬 저장소 사용방법, 동영상 재생방법, 새로운 form형식 적용등 다양한 HTML5를 접할 수 있는 재미있는 책이다. 하지만 개인적으로 자바스크립트 소스는 영 아니다. 책의 예제처럼 코딩하면 안된다는 것.

설정

트랙백

댓글

1 2 3 4 5 ... 76