Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[ADR] JMAP: Avoid ElasticSearch on critical reads
  • Loading branch information
chibenwa committed Nov 11, 2020
commit 8deb1901927181278e1f3cfdab7774ea7a44a694
55 changes: 55 additions & 0 deletions src/adr/0043-avoid-elasticsearch-on-critical-reads.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 43. Avoid ElasticSearch on critical reads

Date: 2020-11-11

## Status

Accepted (lazy consensus).

Scope: Distributed James

## Context

James powers the JMAP protocol.
Comment thread
chibenwa marked this conversation as resolved.
Outdated

A user willing to use a webmail will end up doing the following operations:
- `Mailbox/get` to retrieve the mailboxes. This call is resolved against metadata stored in Cassandra.
- `Email/query` to retrieve the list of emails. This call is nowadays resolved on ElasticSearch.
Comment thread
chibenwa marked this conversation as resolved.
Outdated
- `Email/get` to retrieve various levels of details. Depending of requested properties, this is either
Comment thread
chibenwa marked this conversation as resolved.
Outdated
resolved on Cassandra alone or on ElasticSearch.
Comment thread
chibenwa marked this conversation as resolved.
Outdated

So, ElasticSearch is queried on every JMAP interaction. Administrators thus need to enforce availability and good performance
Comment thread
chibenwa marked this conversation as resolved.
Outdated
for this component.

Relying on more software for every read also harms our resiliency as ElasticSearch outages have major impacts.
Comment thread
chibenwa marked this conversation as resolved.
Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you expect? If you loose any service you loose James availability: S3, Cassandra, RabbitMQ, ElasticSearch.
Why would we want to support unavailability of highly available services in the first place?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I loose ES, given that ADR content, I only loose advanced search.

My customers will be waaaay less complaining about "not having search" that "not being able to read their emails".

Why would we want to support unavailability of highly available services in the first place?

I and the people I work with are human, we do software, there will be unavailability on some of those services.

The question now is how we deal with it.


Also we should mention our ElasticSearch implementation in Distributed James suffer the following flows:
Comment thread
chibenwa marked this conversation as resolved.
Outdated
- Updates of flags leads to updates of the all Email object, leading to sparse segments
Comment thread
chibenwa marked this conversation as resolved.
Outdated
- We currently rely on scrolling for JMAP (in order to ensure messageId uniqueness in the response while respecting limit & position)
- We noticed some very slow traces against ElasticSearch, even for simple queries.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any clue why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And clue why.

But ElasticSearch slow performance likely would require its own ADR. That's a lengthy topic.

Paging is one, there's many others. I described scrolling & data mutabilityu above.


Regarding Distributed James data-stores responsibilities:
- Cassandra is the source of truth for metadata, its storage need to be adapted to known access patterns.
Comment thread
chibenwa marked this conversation as resolved.
Outdated
- ElasticSearch allows resolution of arbitrary queries, and perform full text search.
Comment thread
chibenwa marked this conversation as resolved.
Outdated

## Decision

Provide an optional view for most common `Email/query` requests both on Draft and RFC-8621 implementations.
This includes filters and sorts on 'sentAt'.

This view will be stored on Cassandra, and updated asynchronously via a MailboxListener.
Comment thread
chibenwa marked this conversation as resolved.
Outdated

## Consequences

A migration task will be provided for new adopters.

Administrators would be offered a configuration option to turn this view on and off as needed.

If enabled administrators would no longer need to ensure high availability and good performances for ElasticSearch.
Comment thread
chibenwa marked this conversation as resolved.
Outdated
We thus expect a decrease in overall ElasticSearch load, allowing savings compared to actual deployments.
Furthermore, we expected better performances by resolving such queries against Cassandra.
Comment thread
chibenwa marked this conversation as resolved.
Outdated

## Alternatives

Those not willing to adopt this view will not be affected. By disabling the listener and the view usage, they will keep
Comment thread
chibenwa marked this conversation as resolved.
resolving all `Email/query` against ElasticSearch.
Comment thread
chibenwa marked this conversation as resolved.