Skip to main content

Databases

Ember Nexus stores the data of an element in several databases, each one doing what it is best at. They are either primary or secondary:

  • A primary database holds the original copy of a piece of data, nothing else generates or supplies it.
  • A secondary database holds data which is derived from the primary databases, and which can be rebuilt from them.
DatabaseKindHolds
Neo4jprimaryThe graph: nodes, relations, ownership and access, scalar properties
MongoDBprimaryObjects, lists, vectors, geo values and long strings
ElasticsearchsecondaryA copy of the properties for the search
S3primaryThe files of elements

Every property is stored in exactly one primary database. Which one is decided by the placement of the schema, and every type lists the databases which can store it.

Why Elasticsearch is secondary

Elasticsearch is great at searching, but not a good place for the only copy of data:

  • It is not real-time: written documents become searchable after the next refresh, about one second later. Reading an element right after a write has to return the written data, which the primary databases guarantee.
  • It can be rebuilt from the primary databases at any time, e.g. after a change of a mapping, which would be impossible if it held data on its own.
  • Backups only read the primary databases, and loading one rebuilds the search copy.

The setting search of a property therefore only decides whether the property is copied to Elasticsearch, never where it is stored.

Why Neo4j is always needed

Access to every element is decided by the relations of the graph, see the access model. A graph database is therefore required for every request, even if all properties of a type are stored in MongoDB.

Limits

Most limits which you can run into do not come from the API, but from the databases. Every database page lists the limits which matter in practice, e.g. the maximum size of a MongoDB document or the number of fields of an Elasticsearch index. The limits which the API enforces itself are listed in limits.