Presentation is loading. Please wait.

Presentation is loading. Please wait.

A whirlwind tour Aran Elkington. Open-source Networked / Distributed In-memory  fast Essentially a Key-value data store Optional durability.

Similar presentations


Presentation on theme: "A whirlwind tour Aran Elkington. Open-source Networked / Distributed In-memory  fast Essentially a Key-value data store Optional durability."— Presentation transcript:

1 A whirlwind tour Aran Elkington

2 Open-source Networked / Distributed In-memory  fast Essentially a Key-value data store Optional durability Written by Italian developer Salvatore Sanfilippo Redis is a NoSql database written in ANSI C

3 Salvatore started Redis in early Deployed in June 2009 rapidly it grew in popularity. Salvatore added features at a very rapid pace and rectified all reports of database corruption, instability, etc. In March of 2010 VMWare hired Salvatore to work full-time on Redis. (Redis itself remains BSD licensed.) Shortly thereafter, VMWare hired Pieter Noordhuis, a key Redis contributor, to help Salvatore. Since June 2010 Redis jobs have increased 524% History

4 I think that what’s particularly hard with C is not the details about pointers, automatic memory management, and so forth, but the fact that C is at the same time so low level and so flexible. So basically if you want to create a large project in C you have to build a number of intermediate layers (otherwise the code will be a complete mess full of bugs and 10 times bigger than required). This continuous design exercise of creating additional layers is the hard part about C. You have to get very good at understanding when to write a function or not, when to create a layer of abstraction, and when it’s worth to generalize or when it is an overkill. Posted 18th December 2009 at 3:50 pm18th December 2009 Quote from Salvatore

5 In its outer layer, the Redis data model is a dictionary where keys are mapped to values. In its inner layer these values can be various data structures with different operations you can perform upon them String Redis Strings are binary safe Up to a max size of 512 Megabytes Use Strings as atomic counters using INCR, DECR, INCRBY.INCRDECRINCRBY Append to strings with the APPEND command.APPEND

6 Lists Simply lists of strings, sorted by insertion order can insert or delete at constant time from head or tail, even with many millions of inserted items Hashes Collection of maps between string fields and string values. With up to one hundred or so pairs you can store millions of hashes in a small Redis instance. Sorted Sets Collections of non-repeating elements ordered by a floating-point number called “score”. While members are unique, scores may be repeated. Sets Collections of non-repeating unsorted elements. It is possible to add, remove, and test for existence of members in constant time regardless of Set size

7 List Operations

8 Set Operations

9 Sorted Set Operations

10 Hashes Operations

11 Replication Redis supports master-slave replication. Data from any Redis server can replicate to any number of slaves. A slave may be a master to another slave. This allows Redis to implement a single-rooted replication tree If you set up a slave, upon connection it sends a SYNC command. The master collects all new commands received that will modify the dataset. And transfers the database file to the slave To configure replication is trivial: just add the following line to the slave configuration file: slaveof

12 The County of Los Angeles actively promotes and is committed to ensure a work environment that is free from any discriminatory influence be it actual or perceived. As such, it is the County's expectation that our manufacturers, suppliers and contractors make a concentrated effort to ensure that any equipment, supplies or services that are provided to County departments do not possess or portray an image that may be construed as offensive or defamatory in nature. One such recent example included the manufacturer's labeling of equipment where the words "Master/Slave" appeared to identify the primary and secondary sources. Based on the cultural diversity and sensitivity of Los Angeles County, this is not an acceptable identification label. We would request that each manufacturer, supplier and contractor review, identify and remove/change any identification or labeling of equipment or components thereof that could be interpreted as discriminatory or offensive in nature before such equipment is sold or otherwise provided to any County department. Thank you in advance for your cooperation and assistance. Joe Sandoval, Division Manager Purchasing and Contract Services Internal Services Department County of Los Angeles

13 Persistence RDB Performs point-in-time snapshots at specified intervals. AOF Logs every write operation received using Redis protocol in an append-only fashion that can be replayed. Advantage Compact single-file point-in-time Perfect for backups transferred to far data centers for DR Maximizes Redis performances Allows faster restarts Durable and Flexible: fsync every second, not at all or every query. Append only no seeks, no corruption Log easy to understand and parse Disadvantage Data loss possible in crash if between snapshots Needs to fork() often which be time consuming if the dataset is big Files bigger than RDB files Can be slower then RDB depending on the exact fsync policy. RDB provides more guarantees about maximum latency

14 Example App Code: github Used F# and ServiceStack.Redis client on a.Net stack Tried to stick with a schema. "object-type:id:field“ – “file:1000:name". – Use dots for multi-words fields, like in "comment:1234:reply.to".

15 API’s and Clients Loads of Clients: C, C++, C#, Clojure, Erlang, Go, Haskell, Java, Lua, Node.js, Objective-C, Perl, PHP, Python, Ruby, Scala – Store Strings or Serialize objects Object-hash mapping library for Redis – Inspired from Ruby’s ohm ॐ (Object-hash mapping) created by soveran ( Michel Martens – Argentina) soveran – JOhm for Java, created by xetorthio JOhm – Lohm for Lua, created by slact Lohm – Nohm for Node.js, created by maritz Nohm – Redisco for Python, created by iamteem Redisco

16 Conclusion Redis is: – Fast with lots of persistence options – Flexible data structures – Lots of operations run on the server – Distributed [master -> slave (master) -> slave] – Easy to program with in almost any language I may add I have thoroughly enjoyed this exercise and look forward to using Redis in the future

17 Links Official Redis Documentation at redis.io – The Little Redis Book– free ebook – Redis, from the Ground Up – ground-up.html#heading_toc_j_0 ground-up.html#heading_toc_j_0 Thanks to Chris Petrilli for pics:


Download ppt "A whirlwind tour Aran Elkington. Open-source Networked / Distributed In-memory  fast Essentially a Key-value data store Optional durability."

Similar presentations


Ads by Google