MozillaFoundation / engineering-handbook

Mozilla Foundation's Engineering Handbook
https://mozillafoundation.github.io/engineering-handbook/
13 stars 11 forks source link

Sisyphus: The Big Batch Wolf #49

Closed simonwex closed 3 years ago

simonwex commented 9 years ago

Front-end

Goal: Create a mostly "offline" experience by aggregating project modifications and only saving these to the database at specific times, firing off all operations as an ordered batch update

Original Solution:

Implement java-side object caching (https://github.com/mozilla/webmaker-android/pull/2414) so that edits can be made to pages and elements without needing to synchronize with the database every time a webview is swapped in or out.

Rather than syncing with the database, objects that need to be shared between multiple webviews (effectively: different React applications running in different "tabs") can be cached to java when one view swaps out, and then be retrieved from cache when another view is swapped in, bypassing the need for an external database until the user leaves the page view, at which point all pending modifications for that page get synchronised with the database using a single HTTP call that contains a batch of sequential updates.

This touches quite a few aspects of the code, documented in https://github.com/mozilla/webmaker-core/wiki/Mostly-offline-java-caching-diagrams but summarized here:

With this in place, modifications need only be synchronized with the database when a page view is exited. This is, in fact, still an incomplete solution, and the modifications that are necessary to make this synchronisation only occur when a project is considered "done" (or needing to be saved by the user) have not yet been put in place, instead having been scheduled as follow up (https://github.com/mozilla/webmaker-core/issues/452, with https://github.com/mozilla/webmaker-core/issues/451 as a clean-up followup)

Problems encountered:

Goal: Support front-end requirements to limit network requests to a minimum

Original Solution:

Given an array of actions, reduce into an array of results http://git.io/vOX0w && http://bit.ly/1M5h5AO

(I tried to do the nested list justice in MD, but I think I failed. This further illustrates some of the problems outlined below) - Simon

Problems:

cadecairos commented 9 years ago

Possible solutions

  1. Refactor API to use a document based data store where we can merge new versions of projects fairly effortlessly (VS relational DB style of tables linked via foreign keys)
  2. Refactor the code:
    • Postgres code could be exposed to outside modules, allowing us to move logic out of the lib/postgres.js file and into more specific modules.
    • refactor the bulk endpoint code to be less reliant on scoped variables to reduce complexity
  3. Create documentation for the possible actions that can be sent to the bulk API, as well as the placeholder format (+result set properties available)

These are non-exclusive of each other

Pomax commented 9 years ago

What are next steps for the app

What have we learned already