更新: | 2013-12-27 |
---|---|
バージョン: | 1.5.1 |
作者: | @voluntas |
URL: | http://voluntas.github.io/ |
#NoSQLデータモデリング技法
原文:NoSQL Data Modeling Techniques « Highly Scalable Blog
I translated this article for study. contact matope[dot]ono[gmail] if any problem.
NoSQLデータベースはスケーラビリティ、パフォーマンス、一貫性といった様々な非機能要件から比較される。NoSQLのこの側面は実践と理論の両面からよく研究されている。ある種の非機能特性はNoSQLを利用する主な動機であり、NoSQLシステムによく適用されるCAP定理がそうであるように分散システムの基本的原則だからだ。一方で、NoSQLデータモデリングはあまり研究されておらず、リレーショナルデータベースに見られるようなシステマティックな理論に欠けている。本稿で、私はデータモデリングの視点からのNoSQLシステムファミリーの短い比較といくつかの共通するモデリングテクニックの要約を解説したい。
本稿をレビューして文法を清書してくれたDaniel Kirkdorfferに感謝したいと思う
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Backend(object): | |
def __init__(self): | |
engine = create_engine("mysql://{0}:{1}@{2}/{3}".format(options.mysql_user, options.mysql_pass, options.mysql_host, options.mysql_db) | |
, pool_size = options.mysql_poolsize | |
, pool_recycle = 3600 | |
, echo=options.debug | |
, echo_pool=options.debug) | |
self._session = sessionmaker(bind=engine) | |
@classmethod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TornadoPubSub(redis.client.PubSub): | |
""" | |
PubSub handler that uses the IOLoop from tornado to read published messages | |
""" | |
_stream = None | |
def listen(self): | |
""" | |
Listen for messages by telling IOLoop what to call when data is there. | |
""" | |
if not self._stream: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 2; | |
error_log /var/log/nginx/error.log; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
use epoll; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is a simple example of WebSocket + Tornado + Redis Pub/Sub usage. | |
Do not forget to replace YOURSERVER by the correct value. | |
Keep in mind that you need the *very latest* version of your web browser. | |
You also need to add Jacob Kristhammar's websocket implementation to Tornado: | |
Grab it here: | |
http://gist.github.com/526746 | |
Or clone my fork of Tornado with websocket included: | |
http://github.com/pelletier/tornado | |
Oh and the Pub/Sub protocol is only available in Redis 2.0.0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from: http://www.tornadoweb.org/documentation | |
# running-tornado-in-production | |
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log; | |
pid /var/run/nginx.pid; | |
events { |