Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Redis as datastore #133

Closed
11 tasks
vekexasia opened this issue Mar 17, 2018 · 0 comments
Closed
11 tasks

Use Redis as datastore #133

vekexasia opened this issue Mar 17, 2018 · 0 comments
Projects

Comments

@vekexasia
Copy link
Contributor

vekexasia commented Mar 17, 2018

Redis is capable of an outstanding amount of op/secs. Instead of using postgres as single datastore we should put redis in front of postgres ensuring a fair amount of operations per second.

Proposed solution

  • Redis being used to perform all simple read/write operations
  • Postgres being used as a readonly mechanism for APIs leveraging SQL
  • Postgres being used as a slow - sync later - datastore

What needs to be done for this to work

  • Implement a sync mechanism
    • When a new block is added to redis it should be added to postgres within a convenient timeframe
    • When a new block is removed it should be removed from pg too.
  • Writes should be only performed in a single point of code and only blocks and transactions should be written directly from code. (see below)
  • Account updates (balances, votes, etc) should be done using a postgres data trigger.
  • When node starts redis must be cleaned and restored using data coming from PG.
  • We should calculate the amount of memory needed to store the needed data in memory (Redis) and prompt the node operator if there is not enough ram available.
  • In memory data should not expire.
  • retry mechanism in case data saving fails.
  • automatic process exit if slow-storage is too desyncd from "fast-storage" (Forcing node to rollback to last version in db). NOTE: in sync mode slow-storage could easily be out-of-sync by several blocks. A timestamp mechanism should also be used.
  • produce tuned redis.conf

What are the benefits

  • Slow I/O separation from main logic.
  • postgres will become the ultimate source of truth.
  • atomic block saving easier to perform.
  • Better TPS value (see Enhance TPS value #121)
  • Partial achievement of CQRS.
  • Possibility to log all slow-storage write operations for better debugging.

Edit: Not needed right now.

@vekexasia vekexasia added this to To do in 1.1.0 via automation Mar 17, 2018
@vekexasia vekexasia moved this from To do to Done in 1.1.0 Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
1.1.0
  
Done
Development

No branches or pull requests

1 participant