locomotor transparent migration of client side database
play

Locomotor Transparent Migration of Client-Side Database Code - PowerPoint PPT Presentation

Locomotor Transparent Migration of Client-Side Database Code Michael Mior University of Waterloo Complex database operations often require queries and updates to be mixed with application code Stored Procedures Using stored


  1. Locomotor Transparent Migration of Client-Side Database Code Michael Mior – University of Waterloo

  2. ▸ Complex database operations often require queries and updates to be mixed with application code Stored Procedures ▸ Using stored procedures can reduce latency by cutting back on round trips

  3. ▸ Server-side scripting languages differ from the language used to develop the application Stored Procedures ▸ Independent maintenance is required ▸ Required data needs to be carefully transferred in both directions

  4. ▸ Automatically convert annotated Python functions into server-side Lua scripts in Redis Locomotor ▸ Patch the Python code at runtime to call the dynamically-generated script ▸ Updated code is automatically re-translated and deployed

  5. Redis Data Model Key-value store where values can be Shipping complex types (e.g. maps, lists) Example item:1 → { name: 'Foo', category: 'Bar' } category:Bar → ['item:1', … ]

  6. Application Code hmset('item:' + str(key), {'name': 'Foo'}) lpush('category:Books', 'item:1') Shipping Example ids = lrange('category:' + category, 0, -1) items = [] for id in ids: items.append(hget(id, 'name')) return items

  7. Application Code Each of these calls hmset('item:' + str(key), {'name': 'Foo'}) hmset requires a round trip lpush('category:Books', 'item:1') lpush Shipping to the server! Example lrange ids = lrange('category:' + category, 0, -1) items = [] And once per iteration for id in ids: for id in ids: hget items.append(hget(id, 'name')) return items

  8. Server Script local category = 'category:' .. ARGV[1] local item_keys = redis.call('lrange', Shipping 'category:' .. category, 0, -1) Example local items = {} for _, key in ipairs(item_keys) do table.insert(items, redis.call('hget', key, 'name')) end return items

  9. Server Script local category = 'category:' .. ARGV[1] local item_keys = redis.call('lrange', Shipping 'category:' .. category, 0, -1) Example local items = {} for _, key in ipairs(item_keys) do table.insert(items, redis.call('hget', key, 'name')) end Only one round trip needed return items

  10. 1. Data type conversions 2. Differing language semantics Auto 3. Built-in functions Translate 4. Loop constructs …

  11. Each time an annotated function is run, it is translated/shipped on the fly Deploy @redis_server def get_category(redis, cat): ...

  12. Evaluation Client

  13. ● Shipping code reduced round trips from 24 to 8 Evaluation ● With an inefficient server-side implementation, we still achieve a 4× reduction in runtime

  14. ▸ Translation of client code to server-side scripting languages is a viable approach to optimization Summary ▸ This optimization can be automated with careful observation of language semantics

  15. ▸ Explore other DB/language combos such as MongoDB and JavaScript Future ▸ Automated selection of code fragments Work to translate and move ▸ Use of low-level interfaces (e.g. Redis modules)

  16. Questions?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend