Home > Software engineering >  is there any issue if i using ElasticSearch instead of relational database?
is there any issue if i using ElasticSearch instead of relational database?

Time:09-27

as the question title, if crud data directly through elasticsearch without relation database(mysql/postgresql), is there any issue here? i know elasticsearch good at searhing, but if update data frequencies, maybe got bad performance?

if every update-request setRefreshPolicy(IMMEDIATE), maybe got bad performance also?

CodePudding user response:

ElasticSearch will likely outperform a relational db on similar hardware, though workloads can vary. However, ElasticSearch can do this because it has made certain design decisions that are different than the design decisions of a relational database.

ElasticSearch is eventually consistent. This means that queries immediately after your insert might still get old results. There are things that can be done to mitigate this but nothing will eliminate the possibility.

Prior to version 5.x ElasticSearch was pretty good at losing data when bad things happen the 5.x release was all about making Elastic more robust in those regards, and data loss is no longer the problem it was previously, though potential for data loss still exists, particularly if you make configuration mistakes.

If you frequently modify documents in ElasticSearch you will generate large numbers of deleted documents as every update generates a new document and marks an old document as deleted. Over time those old documents fall off, or you can force the system to clean them out, but if you are doing rapid modifications this could present a problem for you.

CodePudding user response:

The application I am working for is using Elasticsearch as the backend. There are 9 microservices connecting to this backend. Writes are fewer when compared to reads. Our write APIs have a performance requirements of max. 3 seconds.

We have configured 1 second as the refresh interval and always using WAIT_FOR instead of IMMEDIATE and fewer times using NONE in the case of asynchronous updates.

  • Related