• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Scaling GIS Data in Non-relational Data Stores
 

Scaling GIS Data in Non-relational Data Stores

on

  • 29,718 views

As the amount of GIS data we need to keep track of increases, the amount of devices accessing it increases, and the amount of GIS writes increase, we’re finding that, much like real-time web ...

As the amount of GIS data we need to keep track of increases, the amount of devices accessing it increases, and the amount of GIS writes increase, we’re finding that, much like real-time web applications, normal RDBMS’s are not well suited to scaling. This talk covers why GIS data is hard to scale in a normal RDBMS, what nonrelational stores exist out there, and some basic examples of how to do spatial queries within a nonrelational store.

Statistics

Views

Total Views
29,718
Views on SlideShare
21,962
Embed Views
7,756

Actions

Likes
54
Downloads
624
Comments
2

40 Embeds 7,756

http://readwrite.com 3634
http://www.readwriteweb.com 3383
http://highlyscalable.wordpress.com 223
http://www.cloudcamb.org 148
http://www.scoop.it 118
http://www.slideshare.net 80
http://lanyrd.com 35
http://seenthis.net 22
http://codingproblems.wordpress.com 16
http://zeigertelegraph.gfz-potsdam.de 11
http://jetlib.com 10
http://paper.li 10
https://www.readwriteweb.com 9
http://www.seofacts.biz 8
http://translate.googleusercontent.com 5
http://www.strategiescloud.fr 3
http://elsterama.com 3
http://swik.net 3
http://twitter.com 3
http://www.demo.crescosolution.com 3
http://www.netvibes.com 3
http://www.techgig.com 3
url_unknown 2
http://ectimes.com 2
http://developersarena.com 2
https://twitter.com 2
http://readwriteweb.com 2
https://si0.twimg.com 1
https://readwrite.com 1
http://mongopi.wordpress.com 1
http://www.alltechienews.com 1
http://www.xydo.com 1
http://social-news-jp.blogspot.com 1
http://www.elsterama.com 1
http://zeigertelegraph 1
http://webcache.googleusercontent.com 1
http://jainsoninfotech.com 1
http://feedsanywhere.com 1
http://www.klektd.com 1
http://www.tumblr.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

12 of 2 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • So first of all, I&#x2019;ve been head-down coding like 14 hours a day for the past couple weeks. So these slides aren&#x2019;t as polished as I&#x2019;d like them to be. Luckily, I&#x2019;ve been working on exactly this stuff, so it&#x2019;s all in the front of my mind. And since this is a workshop I can be more interactive. Interrupt with questions any time! <br />
  • <br />
  • I&#x2019;ve been interested in GIS for a while, but I&#x2019;m relatively new to the scene. I&#x2019;ve done lots of work building scalable websites though. And, honestly, that&#x2019;s a problem that&#x2019;s more or less solved. <br />
  • HTTP has no &#x201C;session state,&#x201D; but applications that communicate via HTTP do have to maintain state. Without application state there&#x2019;d really be no reason to have a web site or web service - if there&#x2019;s no application state (nothing the web server knows that the client doesn&#x2019;t) then the algorithm can be completely distributed. <br />
  • <br />
  • And, the truth is, relational databases are pretty awesome. They have a number of great characteristics. They&#x2019;re well understood. And they&#x2019;re robust. <br />
  • <br />
  • Most RDBMS systems are ACID compliant or at least pretty close. These characteristics allow client code to make simplifying assumptions about the data that is returned from the data store. <br />
  • RDBMS weaknesses are essentially the inverse of their strengths. <br />
  • The upshot of all this is that write performance is much poorer than read performance. But writes are much harder to scale than reads because they have to happen on an authoritative node. Reads can be scaled easily using replication. <br />
  • <br />
  • Popularized by Eric Brewer at Principles of Distributed Computing in 2000. Brewer&#x2019;s Conjecture. Later formally proven. <br /> <br /> You can design a scalable architecture that maintains some of the ACID characteristics of a typical relational datastore, but eventually you&#x2019;ll have to relax some of these constraints. <br /> <br /> Note that consistency, as defined here, does not mean the same thing as &#x201C;consistency&#x201D; in &#x201C;ACID&#x201D; - before it meant that all data constraints were met. <br />
  • So this is probably something you&#x2019;ve heard before. And people often just throw it out there without an explanation. But it&#x2019;s pretty easy to prove to yourself by contraction, so let&#x2019;s try that. <br />
  • Node A and B are a master/master pair, so they replicate data to one another. To meet the ACID requirements both nodes have to write the data durably before one of them can respond successfully to a write. <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Abstraction layers: sharding, caching, and client-side replication are basically kludges on top of relational data stores that trade consistency for availability and partition tolerance - but why re-invent the wheel? <br />
  • Specialized data stores: graph databases, document databases, key-value stores, and various combinations. <br />
  • Facebook&#x2019;s Hive project adds SQL on top of HBase, but SQL queries are translated into map-reduce jobs that are run across the distributed system <br />
  • Specialized data stores: graph databases, document databases, key-value stores, and various combinations. <br />
  • We should probably call these datastores NoACID instead of Nonrelational or NoSQL. <br />
  • That&#x2019;d make much more sense. But I digress. <br />
  • Eventual consistency is a concept that was popularized by Amazon CTO Werner Vogel. <br /> <br /> This is a gross simplification, and the approaches data stores take to perform node recovery, rebalancing, and repair are often their most distinguishing characteristics. This is actually why we chose Cassandra - the distributed cluster logic is more robust than any other store I&#x2019;ve seen. <br />
  • <br />
  • <br />
  • <br />
  • The outermost layer is the key. <br />
  • Column families are stored together on disk and are the next layer of the structure. <br />
  • And finally we have columns. You can have as many of them as you want, and each row and column family can have different columns. It&#x2019;s schema-less - thus non-relational. <br />
  • <br />
  • Cassandra partitioners are used to decide which node data should be stored on and which node responds to a query. <br />
  • If we can get our data to fit model where we&#x2019;re simply retrieving items by key from a sorted set then it&#x2019;s pretty easy to store and query efficiently. Anything more complicated usually requires heuristics and deep insight into the data set to do at scale. <br />
  • At the very least we need to index on (latitude, longitude)... may also need to through altitude and time into the mix. That&#x2019;s four dimensions. <br />
  • Space-filling curve: developed by Peano, refined by Hilbert. <br />
  • <br />
  • <br />
  • <br />
  • The non-algorithmic approach is a massive undertaking that requires constant attention and involves a large amount of ambiguity. <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • Ask me questions! <br />

Scaling GIS Data in Non-relational Data Stores Scaling GIS Data in Non-relational Data Stores Presentation Transcript

  • Scaling GIS Data in Nonrelational Data Stores featuring Mike Malone Tuesday, March 30, 2010
  • Mike Malone @mjmalone Tuesday, March 30, 2010
  • Tuesday, March 30, 2010
  • SimpleGeo Scalable turnkey location infrastructure Allows you to easily add geo-aware features to an existing application That result: we need to store and query lots of data (data set is already approaching 1TB, and we haven’t launched) Tuesday, March 30, 2010
  • Scaling HTTP is easy No shared state - shared-nothing architecture • HTTP requests contain all of the information necessary to generate a response • HTTP responses contain all of the information necessary for clients to interpret them • In other words, requests are self-contained and different requests can be routed to different servers Uniform interface - allows middleware applications to proxy requests, creating a tiered architecture and making load balancing trivial Tuesday, March 30, 2010
  • So what’s the problem? Individual HTTP requests have no shared state, but the applications that communicate via HTTP can and do Application state has to live somewhere • Path of least resistance is usually a relational database • But RDBMSs aren’t always the best tool for the job Tuesday, March 30, 2010
  • Desirable Data Store Characteristics Massively distributed Horizontally scalable Fault tolerant Fast Always available Tuesday, March 30, 2010
  • Relational Databases Based on the “relational model” first proposed by E.F. Codd in 1969 Tons of implementation experience and lots of robust open source and proprietary implementations Tuesday, March 30, 2010
  • RDBMS Strenghts Theoretically pure Clean abstraction Declarative syntax Mostly standardized Easy to reason about data Tuesday, March 30, 2010
  • ACID Atomicity - if one part of a transaction fails, the entire transaction fails Consistency - all data constraints must be met for a transaction to be successful Isolation - other operations can’t see a transaction that has not yet completed Durability - once the client has been notified that a transaction succeeded, the transaction will not be lost Tuesday, March 30, 2010
  • RDBMS Weaknesses SQL is opaque, and query parsers don’t always do the right thing • Geospatial SQL is particularly bad The best ones are crazy expensive Really bad at scaling writes Strong consistency requirements make horizontal scaling difficult Tuesday, March 30, 2010
  • RDBMS Writes Relational databases almost always use B- Tree (or some other tree-based) indexes Writes are typically implemented by doing an in-place update on disk • Requires random seek to a specific location on disk • May require additional seeks to read indexes if they outgrow the disk cache Disk seeks are bad. Tuesday, March 30, 2010
  • CAP Theorem There are three desirable characteristics of a shared data system that is deployed in a distributed environment like the web. Tuesday, March 30, 2010
  • CAP Theorem 1. Consistency - every node in the system contains the same data (e.g., replicas are never out of date) 2. Availability - every request to a non-failing node in the system returns a response 3. Partition Tolerance - system properties (consistency and/or availability) hold even when the system is partitioned and data is lost Tuesday, March 30, 2010
  • CAP Theorem Choose two. Tuesday, March 30, 2010
  • Client reads & writes reads & writes replicates Node A Node B Tuesday, March 30, 2010
  • Client writes replicates Node A Node B Tuesday, March 30, 2010
  • Client responds acknowledges Node A Node B Tuesday, March 30, 2010
  • Client responds o noes! Node A Node B Tuesday, March 30, 2010
  • What now? 1. Write fails: data store is unavailable 2. Write succeeds on Node A: data is inconsistent Tuesday, March 30, 2010
  • RDBMS Consistency Relational databases prioritize consistency Large scale distributed systems need to be highly available • As we add servers, the possibility of a network partition or node failure becomes an inevitability We could write an abstraction layer on top of a relational data store that trades consistency for availability Or we could switch to a data store that prioritizes the characteristics we really want Tuesday, March 30, 2010
  • Nonrelational DBs Over the past couple years, a number of specialized data stores have emerged • CouchDB • Redis • Cassandra • MongoDB • Dynamo • SimpleDB • BigTable • Memcached • Riak • MemcacheDB Tuesday, March 30, 2010
  • Also Known As NoSQL Not entirely appropriate, since SQL can be implemented on non-relational DBs But SQL is an opaque abstraction with lots of features that are difficult or impossible to efficiently distribute Tuesday, March 30, 2010
  • So what’s different? Most “non-relational” stores specifically emphasize partition tolerance and availability Typically provide a more relaxed guarantee of eventually consistent Tuesday, March 30, 2010
  • NoACID Tuesday, March 30, 2010
  • BASE Basically Available Soft State Eventually Consistent Tuesday, March 30, 2010
  • Eventual Consistency Write operations are attempted on n nodes that are “authoritative” for the provided key In the event of a network partition, data is written to another node in the cluster When the network heals and nodes become available again, inconsistent data is updated Tuesday, March 30, 2010
  • SimpleGeo Cassandra No single point of failure Efficient online cluster rebalancing allows for incremental scalability Emphasizes availability and partition tolerance • Eventually consistent • Tradeoff between consistency and latency exposed to the client Battle tested - large clusters at Facebook, Digg, and Twitter Tuesday, March 30, 2010
  • Cassandra Data Model Column - a tuple containing a name, value, and timestamp Column Family - a group of columns that are stored together on disk Row - identifier for a specific group of columns in a column family Super Column - a column that has columns Tuesday, March 30, 2010
  • Cassandra Data Model { '9xj5ss824mzyv.12345': { 'Record': { 'lat': 40.0149856, 'lon': -105.2705456, 'city': 'Boulder', 'state': 'CO' }, }, 'dr5regy3zcfgr.67890': { 'Record': { 'lat': 40.7142691, 'lon': -74.0059729, 'city': 'New York', 'state': 'NY' } } } Tuesday, March 30, 2010
  • Cassandra Data Model { '9xj5ss824mzyv.12345': { 'Record': { 'lat': 40.0149856, 'lon': -105.2705456, 'city': 'Boulder', 'state': 'CO' }, }, 'dr5regy3zcfgr.67890': { 'Record': { 'lat': 40.7142691, 'lon': -74.0059729, 'city': 'New York', 'state': 'NY' } } } Tuesday, March 30, 2010
  • Cassandra Data Model { '9xj5ss824mzyv.12345': { 'Record': { 'lat': 40.0149856, 'lon': -105.2705456, 'city': 'Boulder', 'state': 'CO' }, }, 'dr5regy3zcfgr.67890': { 'Record': { 'lat': 40.7142691, 'lon': -74.0059729, 'city': 'New York', 'state': 'NY' } } } Tuesday, March 30, 2010
  • Cassandra Data Model { '9xj5ss824mzyv.12345': { 'Record': { 'lat': 40.0149856, 'lon': -105.2705456, 'city': 'Boulder', 'state': 'CO' }, }, 'dr5regy3zcfgr.67890': { 'Record': { 'lat': 40.7142691, 'lon': -74.0059729, 'city': 'New York', 'state': 'NY' } } } Tuesday, March 30, 2010
  • Writes are crazy fast Writes are written to a commit log in the order they’re received - serial I/O New data is stored in an in-memory table Memory table is periodically synced to a file Files are occasionally merged Reads may end up checking multiple files (bloom filter helps) and merging results • Thats okay because reads are pretty easy to scale Tuesday, March 30, 2010
  • How can I query? Depends on the partitioner you use • Random partitioner: makes it really easy to keep a cluster balanced, but can only do lookups by row key • Order-preserving partitioner: stores data ordered by row key, so it can query for ranges of keys, but it’s a lot harder to keep balanced Tuesday, March 30, 2010
  • BYOI • If you need an index on something other than the row key, you need to build an inverted index yourself • Row key: attribute you're interested in plus row key being indexed • “dr5regy3zcfgr:com.simplegeo/1” • But what about indexing multiple attributes..? Tuesday, March 30, 2010
  • The Curse of Dimensionality Location data is multidimensional Traditional GIS software typically uses some variation of a Quadtree or R-Tree for indexes Like B-Trees, R-Trees need to be updated in-place and are expensive to manipulate when they outgrow memory Tuesday, March 30, 2010
  • Dimensionality Reduction If we think of the world as two-dimensional cartesian plane, we can think of latitude and longitude as coordinates for that plane Instead of using (x, y) coordinates, we can break the plane into a grid and number each box • Space-filling curve: a continuous line that intersects every point in a two-dimensional plane Tuesday, March 30, 2010
  • Tuesday, March 30, 2010
  • Geohash A convenient dimensionality reduction mechanism for (latitude, longitude) coordinates that uses a Z-Curve Simply interleave the bits of a (latitude, longitude) pair and base32 encode the result Interesting characteristics • Easy to calculate and to reverse • Represent bounding boxes • Truncating bits from the end of a geohash results in a larger geohash bounding the original Tuesday, March 30, 2010
  • Geohash Drawbacks Z-Curves are not necessarily the most efficient space-filling curve for range queries • Points on either end of the Z’s diagonal seem close together when they’re not • Points next to each other on the spherical earth may end up on opposite sides of our plane These inefficiencies mean we sometimes have to run multiple queries, or expand bounding box queries to cover very large expanses Tuesday, March 30, 2010
  • Geohash Alternatives Hilbert curves: improve on Z-Curves but have different drawbacks Non-algorithmic unique identifiers • Provide unique identifiers for geopolitical and colloquial bounding polygons • Yahoo! GeoPlanet’s WOEIDs are a good example Tuesday, March 30, 2010
  • Other stuff we use Tuesday, March 30, 2010
  • Memcache Useful for storing ephemeral or short-lived data and for caching Super crazy extra fast Robust support from pretty much every language in the world Tuesday, March 30, 2010
  • MemcacheDB BDB backed memcache We use it for statistics • Can’t use Cassandra because it doesn’t support eventually consistent increment and decrement operations (yet) Giant con: it’s pretty much impossible to rebalance if you add a node Tuesday, March 30, 2010
  • Pushpin Service Custom storage solution R-Tree index for fast lookups Mostly fixed data sets so it’s ok that we can’t update data efficiently Tuesday, March 30, 2010
  • MySQL! Our website still uses MySQL for some stuff... though we’re moving away from it Tuesday, March 30, 2010
  • Thanks! Tuesday, March 30, 2010
  • Ask me questions! @mjmalone Tuesday, March 30, 2010