123
 123

Tip: 看不到本站引用 Flickr 的图片? 下载 Firefox Access Flickr 插件 | AD: 订阅 DBA notes --

2010-02-24 Wed

18:27 Bloom Box (694 Bytes) » 玉面飞龙的BLOG

高科技的能源产品,有氧气和天然气,就可以供给家庭或者办公室,甚至服务器用电,据说节约不少成本,很绿色。

Bloom’s fuel cell works like this: Oxygen is pumped in on one side and natural gas on the other. The two combine inside the cell to create a chemical reaction that produces electricity. No burning, no combustion, no power lines from outside.

fuel cell的internal如此,不管结果怎么样,有VC投钱就有大把的工作岗位。

13:38 An Emerging NoSQL Usecase: Session Storage (1775 Bytes) » MyNoSQL

Storing web apps session information in NoSQL stores seems to be a new and emerging NoSQL usecase. Looking at what is gained from such an approach (schema-less, scalability, performance, replication, etc.) I’d conclude that this is a great NoSQL usecase.

But make sure that even if using this scenario you’ll not try to generalize this sort of very specific benchmarks.

11:45 CBO Surprise 2 (1 Bytes) » Oracle Scratchpad
09:22 NoSQL and RDBMS: Learn from Others' Experience (3917 Bytes) » MyNoSQL

I firstly thought that Innostore[1], the embedded InnoDB from Basho, is just another cool project they’ve made available to the community. It was only after a couple of days that I realized that Innostore is in fact one option for the pluggable Riak backend storage engines. That definitely made me think more about this decision.

Luckily enough, David Smith from Basho has already took the time to explain ☞ the reasons that brought Riak to use InnoDB as one of its storage engines:

1. predictability and 2. stability. […] we need something that is going to have predictable latency under significant loads. After evaluating TokyoCabinent (TC), BerkeleyDB-C (BDB) and Embedded Inno, it was quite clear that Inno won this aspect hands down.

You’ll notice pretty much the same arguments in this post about ☞ MySQL usage at Flickr:

  • it is a very well known component. When you’re scaling a complex app everything that can go wrong, will. Anything which cuts down on your debugging time is gold. All of MySQL’s flags and stats can be a bit overwhelming at times, but they’ve accumulated over time to solve real problems.
  • it’s pretty darn fast and stable. Speed is usually one of the key appeals of the new NoSQL architectures, but MySQL isn’t exactly slow (if you’re doing it right). I’ve seen two large, commercial “NoSQL” services flounder, stall and eventually get rewritten on top of MySQL. (and you’ve used services backed by both of them)

As a side note, that last sentence reminded me of the migration Hashrocket team has completed for a pharma company.

Last, but not least, you can also take a look at this ☞ Yahoo! benchmark that includes MySQL and, if I’m not misinterpreting those results, you’ll notice that for some of them MySQL performed quite well.

I guess what we can learn from all these is:

  • not all traditional storage engines are as bad as we sometimes want to think of them
  • it is probably the complete feature set of the RDBMS that are making them overkill for some projects
  • there are still a lot of scenarios in which an RDBMS makes sense

Strange post for a NoSQL centric blog, isn’t it?

05:22 Using Google's V8 JavaScript Engine with MongoDB (1196 Bytes) » MyNoSQL
Using Google's V8 JavaScript Engine with MongoDB:

Purely geeky: learn how to use the Google V8 JavaScript engine with MongoDB.

Currently the JavaScript engine used is spider monkey (Developed by Mozilla). If you checkout the lastest version of mongoDB you will be able to build it with Google’s V8 JavaScript engine support.

The installation details are for Ubuntu, but who knows maybe somebody can get this to work on Mac OS too.

03:27 Presentation: Redis - REmote DIctionary Server by Ezra Zygmuntowicz (8521 Bytes) » MyNoSQL

Fantastic presentation by Ezra Zygmuntowicz (@ezmobius) on Redis:

My notes from the slides:

Redis usecases:

  • Memcached on steroids
  • Tag clouds, leaderboards
  • Stat collections, circular log buffers
  • Share state between processes
  • A/B testing
  • REDIStribute your load
  • Distributed Lock Manager for process coordination
  • Full Text Inverted Index Lookups
  • Caching with extra smarts using lists, sets and atomic ops on said structures

Some of these usecases are detailed later in the slides. You should definitely check this great list of Redis usecases.

I’ve heard that there might be a video for this presentation, so I hope that will be published pretty soon as I’d really like to include it here with the slides.

You can find below the text on slides (no formatting though)

  • Slide: 1

    Redis

    REmote DIctionary Server

    Ezra Zygmuntowicz

    twitter: @ezmobius

    #redis

  • Slide: 2

    · Fast,in memory key/value store

    · STRING,LIST,SET & ZSET data types

    · Persistence via async snapshots orAOF

    · Perfect Data Structure/State/Cache Server

  • Slide: 3

    Data Structure Server

  • Slide: 4

    Data Structure Server

    Key:String => Value:String

  • Slide: 5

    Data Structure Server

    Key:String => Value:String

    Key:String => Value:List

  • Slide: 6

    Data Structure Server

    Key:String => Value:String

    Key:String => Value:List

    Key:String => Value:Set

  • Slide: 7

    Data Structure Server

    Key:String => Value:String

    Key:String => Value:List

    Key:String => Value:Set

    Key:String => Value:Zset

  • Slide: 8

    Operations on any Type

    · Exists,Del,Type

    · Keys,Randomkey

    · Rename,RenameNX

    · Dbsize,Select,Move,Flushdb,Flushall

    · TTL,Expire

  • Slide: 9

    Operations on STRING’s

    · Get,Set,GetSet,SetNX

    · Mget,Mset,MgetNX,MsetNX

    · Incr,Incrby

    · Decr,Decrby

  • Slide: 10

    Operations on LISTS’s

    · Atomic Operations:

    · Push/Pop

    · Index (array indexing)

    · Lrange,Ltrim,Llen

    · Blpop,Brpop

    · RpopLpush,BRpopLpush

  • Slide: 11

    Operations on SET’s

    · Sadd,Srem,Spop,Smove

    · Scard,Sismember,Smembers,Srandmember

    · Sinter,Sinterstore,Sunion,Sunionstore

    · Sdiff,Sdiffstore

  • Slide: 12

    Operations on ZSET’s

    · Zadd,Zrem,Zincrby

    · Zrange,Zrevrange

    · Zrangebyscore,Zcard

    · Zscore,Zremrangebyscore

  • Slide: 13

    Seems cool, but what are the use cases?

    · Memcached on Steroids

    · Tag Clouds,Leaderboards

    · Stat collections,circular log buffers

    · Share state between processes

    · A/B testing

    · REDIStribute your load

  • Slide: 14

    Example:Tagging

  • Slide: 15

    Example:Tagging

    SADD article:42 magick

    SADD article:42 unicorns

    SADD article:42 rainbows

  • Slide: 16

    Example:Tagging

    SADD article:42 magick

    SADD article:42 unicorns

    SADD article:42 rainbows

    SADD article:12 magick

    SADD article:12 bar

    SADD article:12 qux

    SADD article:12 foo

  • Slide: 17

    Example:Tagging

    SADD article:42 magick

    SADD article:42 unicorns

    SADD article:42 rainbows

    SADD article:12 magick

    SADD article:12 bar

    SADD article:12 qux

    SADD article:12 foo

    SINTER article:42 article:12 

    #=> magick

  • Slide: 18

    Example: Fair Work

    Scheduler

  • Slide: 19

    Example: Fair Work

    Scheduler

  • Slide: 20

    Example: Fair Work

    Scheduler

    Each worker node periodically issues:

    ZADD worker:nodes 1.5 hostname

    1.5 is the load ave of the host

  • Slide: 21

    Example: Fair Work

    Scheduler

    Each worker node listens for work with:

    BLPOP hostname 10 

  • Slide: 22

    Example: Fair Work

    Scheduler

    When a producer wants to issue a work request:

    ZRANGE worker:nodes 0 2 

    returns top 3 least loaded nodes

  • Slide: 23

    Example: Fair Work

    Scheduler

    Pick a random node out of the 3 least loaded nodes in order to add jitter so we don’t overload hosts

  • Slide: 24

    Example: Fair Work

    Scheduler

    Then issue the work request:

    LPUSH hostname {“work”: {“foo”:”bar”}}

  • Slide: 25

    Example: Fair Work

    Scheduler

    This setup uses ZSETS and the load average as a score in order to evenly distribute load across a farm of worker instances listening for jobs with BLPOP

  • Slide: 26

    Example:AMQP

    message de-dupe

  • Slide: 27

    Example:AMQP

    message de-dupe

    Route messages through 2 separate rabbitmq brokers for redundancy

    Use redis for message de-dupe by tagging messages with a guid

    Use guid as key into redis

    Use SETNX when setting the guid key so first one wins and second messages gets discarded as already received

  • Slide: 28

    Other Ideas

    · Distributed Lock Manager for process coordination

    · FullText Inverted Index Lookups

    · Caching with extra smarts using lists,sets and atomic ops on said structures

    · Share data structures between multiple processes like a blackboard/tuplespace

  • Slide: 29

    Speed

    · 110k GETS/SETS/second on average linux box

    · Mostly faster then memcached for same ops

    · Event Driven,can handle thousands of clients with epoll/kqueue support

    · Ops happen in memory,persistence is async so everything is very fast

  • Slide: 30

    Persistence

    · Async Snapshots with configurable triggers

    · Append Only File: AOF

    · Redis 2.0 Virtual Memory

  • Slide: 31

    Replication

    · Built in Master -> SlaveAsync replication

    · Create replication chains as needed

  • Slide: 32

    Sharding

    · Client side sharding (like memcached)

    · Consistent ring hashing

    · Special case keys “foo{tags}” for operations on keys that must live on the same server in ruby client

  • Slide: 33

    Redactor

    · SimpleActor Library based around Redis

  • Slide: 34

    Questions?

02:36 苹果为何不在 iPhone、iPad 平台支持 Flash (7003 Bytes) » DBA Notes

作者:Fenng 发布在 dbanotes.net. BLOG 墙外订阅数量,点击则可进行订阅

iphone-flash-plug.jpg最近 Apple 和 Adobe 之间因为 Flash 的支持与否,口水仗打的比较热闹。个人愚见,苹果公司做出当前的选择应该不是因为乔布斯要逞一时口舌之快,相信是内部自有 iPhone 以来的长期评估后做出的选择,苹果公司从战略层面甚至会把 Adobe 看作竞争对手而不再是重要的合作伙伴,而谢绝 Flash 入内,是一个非常精明的借口。

之所以说二者是竞争关系,关键字还是在于"平台"。Adobe Flash 是当前业界占有率最广泛的一个技术平台,甚至超过大家想当然的 Java 。根据 Adobe 的统计,Flash Player 占领了 99% 可上网电脑设备,有超过 200 万专业用户在使用,这里的专业用户应该指具备一定开发能力的用户,依托于 Flash 的应用程序数量已经相当的惊人。所以,是否在 iPhone 、iPad 上引入 Flash 的支持,从苹果的角度看,这是平台之战,谁也不想引狼入室。我们设想一下假定 Flash 已经得到了苹果公司的支持,那么 Adobe 可以一转身也建立一个 "Flash App Store" 或者类似的东西,开发者可以用上传的小应用,任何平台的用户都可以下载使用。想想对苹果的冲击会有多大? Adobe 或许还没想好如何也建立一个 App Store ,但不排除将来会染指这一块业务。stats_432x309.gif

苹果公司长久以来不太有"开放"的态度,或者说是"封闭的开放",最希望通过自己封闭的环境,让用户通过圈下来的地建立一个生态圈子,不想和其它公司一起合作。乔布斯回归后,通过激发用户对 iPod 喜爱与信赖,进而购买使用 iPhone ;通过 iPhone ,进而使用 iPad ;通过 iPad ,再回去使用 Mac 。这是个非常好的封闭循环过程。开放,会丢掉利润,而封闭,才会让苹果公司有更大收益。当然,我也想说的是,对 Flash 的支持友好也的确有可能让 iPad 在某些方面导致平庸,比如性能。与之类比的是 Firefox ,现在速度问题广为用户诟病,而这问题基本由插件导致的,现在 Chrome 尽管足够快,但随着扩展日益增多,必然重蹈覆辙。

现在乔布斯游说内容提供商加入他的 iPad 阵营,而他之所以敢批评 Flash 的不足,也是因为还有另外的技术路线可选,那就是 HTML5 。但是有多少内容提供商会舍弃 Flash 而加入 HTML 5 的阵营,这个还需假以时日才能看清楚。换做另外一家公司,来自用户的呼声可能都会受不了,对于苹果来说,我行我素是一贯的风格,乔布斯一直是个精明的商人。

是否会在 iPad 上看到 Flash ? 将来或许会,但是这要在乔布斯开给 Adobe 的条件都得到满足的情况下才会出现(没错,这两家现在或许已经在谈判桌上了),这些条件当中,除了解决当前的性能和稳定性问题(这个问题并非原则上的问题),最重要的是 Adobe 不要与苹果有商业利益上的冲突,苹果一定要得到某种承诺,而这,对于 Adobe 来说,也会是艰难的选择。

--EOF--

注:春节期间构思此文,一直没发出来,后来发现有不少人也持类似观点,澄清一下,并非拾人牙慧。

说起平台,国内 360 安全卫士尽管已经取得了惊人的装机量,进而推的浏览器和网址导航也都立竿见影,但是还难脱"工具" 的影子,还是不能形成技术生态环境,我相信不会有类似 "360 平台" 的产品出来的,不是不想,而是做不到。

Sun(Oracle)公布的 Java 在桌面机有 8 亿。


最近文章|Recent Articles

本站赞助商:豆瓣网

评论数(9)|添加评论 | 最近作者还说了什么? Follow Fenng@Twitter
本文网址:

DBA Notes 理念: 用简约的技术取得最大的收益...

01:29 如何提高SQL 查询技能 (4099 Bytes) » dbthink

Robert Vollman 今天发表了一篇由其个人经历总结出来的如何写好Oracle SQL查询的Blog, 本文是对其主要观点的摘录, 这也是Oracle初学者在写SQL是经常遇到的困难.
Improving your SQL Queries By Robert Vollman

  • 记录详细的需求文档
  • 在写SQL之前必须弄清楚需求, 具体要取什么数据, 有些什么具体的约束条件, 在数据仓库环境中还可以考虑补上这个需求具体对应哪些报表, 对应的基础表如何. 到开发环境的话, 可以考虑加上这条SQL服务于哪些业务(页面),调用频率如何.

  • 不要重新制造轮子
  • 对于一些已经比较成熟的解决方案,有比较现成的例子的SQL,要善于利用已有SQL,已有模板.

  • 降低语句的复杂度
  • 有些同学可能比较喜欢使用比较炫的技术,比较炫的SQL来解决问题. 但是要切记一点, 使用过于复杂过于新的技术, 如果不能在性能(以及其他方面)带来好处的话, 只会使得这条SQL难于维护, 使得其他相关人员难于理解.

  • 小心处理NULL
  • NULL在Oracle数据库中是一个非常特别的值, 它不等于任何值, 所以如果你的SQL返回的值数量偏少,或者根本不对很可能就是使用NULL出现了问题..
    常见的情况是:
    1. 查询的时候直接使用条件 colx = xxx,而这个colx里面是有NULL值的, 这种情况下查询的返回结果是不会包含NULL值对应的记录的, 如果要查询出NULL对应的记录, 需要使用 colx is null (is not null).
    2. var 为null的时候, 在plsql中给var赋值, var := var + xxx;这种情况下var的值会一直是null的, 这一点需要特别注意, 我自己也犯过好几次这个错误.

  • 自己核对数据类型
  • 在where条件里面要仔细地核对数据类型, 由于隐形转换的问题, 在数据类型错误的时候, Oracle无法正确使用索引, 可能会导致SQL运行非常慢.

  • 小心处理重复数据
  • 在需求明确的情况下, 如果你不在乎是否出现重复记录, 或者明确知道不会出现重复数据的情况下, 尽量使用Union All而不是Union进行查询, Union会涉及到昂贵的排序操作.

  • 避免不必要的优化操作
  • SQL的性能调优可能非常有趣非常带劲, 但是很多时候调优可能意义不大, 比如对于只会使用一次的查询, 你可能很少在乎是1秒钟结束还是2秒钟结束..

    不过一些基本的优化规则还是要用的:
    只查询你需要的字段, 而不要所有的查询都是用select *来进行.
    在通过索引来查询更合适的时候, 尽量在查询条件中指定有索引的字段来查询. (在返回的记录条数很少的时候, 使用索引一般都能更加快速的得到查询结果.
    不要可以避免使用表连接. 关系数据库就是为了表连接而设计的.

  • 尽可能使用绑定变量
  • 在开发环境使用的SQL语句尽量使用绑定变量, 这样可以大大缓解Oracle数据库解析SQL的消耗, 也可以大大提高数据库的可扩展性.

  • 使用源码控制工具
  • 最好使用CVS/SVN一类的源码控制工具来管理你的SQL/PLSQL代码, 这对于后期的维护有非常大的帮助, 也有助于其他人更好的理解你最初写这条SQL的意图.

  • 测试,测试,测试.
  • 在SQL写好之后, 要深入的进行测试, 以确保其正常运行.

00:35 Python, Django and MongoDB (2794 Bytes) » MyNoSQL

Interested in Python, Django and MongoDB? Then I hope you’ll find these posts interesting:

And then there is this fresh screencast from Kevin Fricovsky talking Django and MongoDB integration. You can read about it ☞ here, but as a quick summary, the screencast will introduce you to mongoengine and then using Django-Mumblr, a NoSQL-based blog engine it will dive deeper into the details of Django and MongoDB integration.

Update: Just found a couple of more MongoDB Django tricks that you may find interesting.

The first one is a solution that provides access to MongoDB document _id’s from Django templates. The ☞ solution is based on a custom Django filter and using it as in {{ object|mongo_id }}

I find the solution pretty odd, not to mention that using a filter for accessing such an important document information seems convoluted. I’d much prefer to have the _id accessible directly on an object through either a field or at least a special property. Behavior for an unsaved document might be as simple as returning None or raising an exception.

The second trick fixes a problem with using Django’s FileWrapper while working with MongoDB’s GridFS. I’d probably be tempted to call this a bug, so before getting it fixed you can read the details ☞ here.

2010-02-23 Tue

11:41 Dynamic Sampling (1 Bytes) » Oracle Scratchpad
07:22 CouchDB List Functions » MyNoSQL
01:51 MongoDB Poster » MyNoSQL

2010-02-22 Mon