Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Tile38 Overview

Tile38 Overview

Transcript

  1. 1 What is Tile38? https://tile38.com/ • Geospatial Database & Geofencing

    Server • Compatible with Redis protocol ◦ RESP2 only ◦ RESP3 is not supported • Uses AOF persistence ◦ Like Redis
  2. 2 Object Type • POINT ◦ plain lat/lon with optional

    z-coord ◦ SET key id POINT 33.5123 -112.2693 ◦ SET key id POINT 33.5123 -112.2693 225 • BOUNDS ◦ rectangle ◦ SET key id BOUNDS 30 -110 40 -100 • OBJECT ◦ geojson, could be point, multipoint, linestring, multilinestring, polygon, multipolygon, geometrycollection etc. ◦ SET key id OBJECT '{"type":"Polygon","coordinates":[[[-111.9787,33.4411],[-111.8902,33.4377],[-11 1.8950,33.2892],[-111.9739,33.2932],[-111.9787,33.4411]]]}'
  3. 4 • SET ◦ Just like Redis ◦ [EX seconds]

    ◦ [NX|XX] ◦ [FIELD name value ...] ▪ can be number or string ◦ SET key id POINT 33.5123 -112.2693 ◦ SET key id FIELD speed 90 FIELD age 21 POINT 33.5123 -112.2693 • GET ◦ Returns geojson by default ◦ Setting the return value types (POINT, BOUNDS) are supported ◦ GET key id ◦ GET key id POINT Object Operations
  4. 6 • Searches a collection for objects that are close

    to a specified point. • Specify a center point, and either a LIMIT or a radius. • Examples: ◦ NEARBY key LIMIT 1 POINTS POINT 33.462 -112.268 ▪ POINTS specify the format for output, and POINT specify the input ◦ NEARBY key POINTS POINT 33.462 -112.268 6000 • Output formats ◦ POINTS (list of latitude, longitude points) ◦ OBJECTS (geojson) ◦ BOUNDS ◦ HASH NEARBY
  5. 7 NEARBY • WHERE ◦ NEARBY key WHERE 'speed >=

    70' POINT 33.462 -112.268 6000 ◦ NEARBY key WHERE 'name = "foo" && age < 30' POINT 33.462 -112.268 6000 • COUNT ◦ NEARBY key COUNT POINT 33.462 -112.268 6000
  6. 8 • Just like NEARBY, but WITHIN and INTERSECTS explicitly

    take area types as input. • The syntax for WITHIN and INTERSECTS are identical. • The only difference is WITHIN does not include the boundary and INTERSECTS includes the boundary. • Input area formats ◦ CIRCLE lat lon radius ◦ GET key id (existing geojson object in the db) ◦ BOUNDS (rectangle bounding box) ◦ ... • Output formats ◦ Same as NEARBY • Example: ◦ INTERSECTS key BOUNDS 33.462 -112.268 33.491 -112.245 WITHIN, INTERSECTS
  7. 9 • Area ◦ Same as NEARBY, WITHIN, INTERSECTS, because

    it was based on those search commands. • WHERE ◦ Same as above. Geofencing
  8. 10 • SETCHAN name NEARBY key FENCE POINT 33.5123 -112.2693

    500 • Channels are persistent just like other data, recoverable after restart. • Clients can use SUBSCRIBE to listen for events. • Pros: ◦ Simple for testing if the fencing works. ◦ Supports multiple consumers. • Cons: ◦ No support for RESP3. ▪ In RESP2, if a client connection subscribes to a channel, it will not be able to send other commands than pub/sub related ones. ▪ In RESP3, Push messages are introduced which can send out-of-band data so that one can reuse the client connection. ◦ Not easy to manage state (disconnection, instance down, tile38 down). Geofencing (Channel)
  9. 11 Geofencing (Webhook) • SETHOOK name http://location_api:3000/hook NEARBY key FENCE

    POINT 33.5123 -112.2693 500 • Webhooks are persistent just like other data, recoverable after restart. • Syntax is almost the same as channels. • Pros ◦ Support a lot of protocols ▪ http(s), gRPC, Redis, Kafka, MQTT, Amazon SQS, Azure Event Hub, Google PubSub, ... ◦ Easier to manage ▪ Tile38 serves as a simple producer of events. • Cons ◦ One and only one consumer.
  10. 13 Geofencing behavior • Objects already inside/ouside the area will

    not trigger `inside`/`outside` until any operation (set, del, drop) on them. • Objects entering the area will trigger `enter` and then `inside`. `command` is `set`. • Objects leaving the area will trigger `exit` and then `outside`. `command` is `set`. • If an object is deleted, an event of `command` being `del` will be triggered without the `detect` and `object` field. There will be no `exit` or `outside` event for this. • `detect` field is only set when `command` is `set`.
  11. 15 • Tile38 replication is a leader-follower model. • The

    leader and followers are assigned manually with FOLLOW commands. There is no built-in election mechanism. • Followers never accept write commands. • For a follower to accept read commands, the follower must have caught up to its leader, otherwise it will reject the commands. Replication
  12. 16 • 100km x 100km square area. • 10k vehicles.

    • 1k geo fences with 1km radius, subscribed to `inside,enter,exit` events for vehicle. • Runs on my local macbook. Benchmark (Settings)
  13. 17 • Target 0.1 QPS for read and write with

    random location for each vehicle, 2k QPS in total, in 1 minute. ◦ Write Operations: 50073 success, 0 failed ◦ Read Operations: 50090 success, 0 failed ◦ Write Latency: avg=59.229665ms, p50=60.004583ms, p95=84.097958ms, p99=86.456708ms ◦ Read Latency: avg=59.16715ms, p50=59.9995ms, p95=84.091958ms, p99=86.455459ms ◦ Geo Fencing: ◦ Channels: 1000 created, 0 failed ◦ Events Received: 51651 (inside: 17235, enter: 17230, exit: 17186) Benchmark (Results)
  14. 18 • Target 0.2 QPS for read and write with

    random location for each vehicle, 4k QPS in total, in 1 minute. ◦ Write Operations: 110020 success, 0 failed ◦ Read Operations: 110024 success, 0 failed ◦ Write Latency: avg=52.321258ms, p50=53.899333ms, p95=75.131667ms, p99=79.640834ms ◦ Read Latency: avg=52.283828ms, p50=53.917959ms, p95=75.114583ms, p99=79.6375ms ◦ Geo Fencing: ◦ Channels: 1000 created, 0 failed ◦ Events Received: 113873 (inside: 37926, enter: 37914, exit: 38033) Benchmark (Results)