$30 off During Our Annual Pro Sale. View Details »

Don't Use NoSQL

Don't Use NoSQL

Mathias Meyer

January 12, 2012
Tweet

More Decks by Mathias Meyer

Other Decks in Technology

Transcript

  1. Don’t Use
    NoSQL
    Mathias Meyer, @roidrage

    View Slide

  2. View Slide

  3. What do we use
    NoSQL for?

    View Slide

  4. Queues

    View Slide

  5. Resque
    Delayed Job
    CouchDB Queue Service
    Replacing RabbitMQ with MongoDB

    View Slide

  6. “Doesn’t matter what kind of tool
    it is, at least one developer
    will eventually use it as a queue.”
    Me, 2012

    View Slide

  7. Analytics

    View Slide

  8. Visitor Tracking
    Split Testing
    API Limiting
    Logging

    View Slide

  9. Schemaless

    View Slide

  10. Documents

    View Slide

  11. Caching,
    Sessions

    View Slide

  12. “Doesn’t matter what kind of
    database it is, at least one developer
    will eventually use it as a cache.”
    Me, 2012-01-11

    View Slide

  13. Why?

    View Slide

  14. We can?

    View Slide

  15. We wants it?

    View Slide

  16. We don’t
    know better?

    View Slide

  17. Cause and Effect

    View Slide

  18. We abuse the
    database as a queue

    View Slide

  19. We hit memory
    limits hard

    View Slide

  20. Transactions

    View Slide

  21. Joins

    View Slide

  22. Schemas

    View Slide

  23. There’s always a
    schema.

    View Slide

  24. We pay for our
    choices.

    View Slide

  25. What to do
    instead?

    View Slide

  26. Use the right tool
    for the job?

    View Slide

  27. How do we know
    the right tool?

    View Slide

  28. RabbitMQ, Kestrel, Gearman
    for queues

    View Slide

  29. Graphite
    for statistics

    View Slide

  30. pt-online-schema-change
    for schema updates
    http://www.percona.com/doc/percona-toolkit/2.0/pt-online-schema-change.html

    View Slide

  31. PostgreSQL Arrays
    for queues?

    View Slide

  32. PostgreSQL Arrays
    for queues?
    for lists

    View Slide

  33. MySQL 5.6 Memcached API
    http://blogs.innodb.com/wp/2011/04/nosql-to-innodb-with-memcached/

    View Slide

  34. HandlerSocket for MySQL
    http://yoshinorimatsunobu.blogspot.com/2010/10/using-mysql-as-nosql-story-for.html

    View Slide

  35. PostgreSQL hstore
    for documents
    http://blog.creapptives.com/post/14062057061/

    View Slide

  36. PostgreSQL XML
    for documents
    http://robots.thoughtbot.com/post/13829210385/

    View Slide

  37. Build your
    own tools.

    View Slide

  38. Learn a new tool
    every month.

    View Slide

  39. Don’t Use NoSQL

    View Slide

  40. Unless you really
    have to.

    View Slide

  41. Thoughts?

    View Slide

  42. Examples

    View Slide

  43. PostgreSQL hstore
    create table herokaih (id serial primary key, attr hstore);
    create index attr_idx on herokaih using gist (attr);
    insert into herokaih (attr)
    values (hstore(ARRAY['name', 'Dylan Egan']));
    select attr -> 'language' from herokaih where attr @>'name=>Dylan';

    View Slide

  44. PostgreSQL XML
    create table herukai (id serial primary key, data xml);
    insert into herukai (data) values
    ('Dylan Eganheroku
    herukai>');
    select xpath('//herukai/name/text()', data) from herukai;
    SELECT * from herukai where (xpath('//herukai/name/text()', data))
    [1]::text = 'Dylan Egan'::text;

    View Slide

  45. PostgreSQL Arrays
    create table herokail (id serial primary key, tags text[], name
    varchar(200));
    insert into herokail (name, tags) values ('Dylan Egan',
    ARRAY['meat']);
    update herokail set tags = array_append(tags, 'beer') where name =
    'Dylan Egan';
    select name from herokail where tags @> ARRAY['beer'];

    View Slide

  46. pt-online-schema-change
    pt-online-schema-change h=127.1,t=users
    --alter “ADD COLUMN twitter_name varchar(40)”
    --drop-old-table

    View Slide