Elasticseach, Redis, Relational Database or whatever?

Asked

Viewed 738 times

2

I’m starting to work with the Elasticsearch and from what I looked so far on the net brought me some doubts.

  1. What is the difference between Elastic and Redis?
  2. It is advantageous to work with a relational bank + Elastic?
  3. It is possible and if it is has advantages in working with Elastic + Redis, Elastic + Relational DB or Elastic + Redis + Relational DB?
  4. When one is indicated and not the other?
  • 1

    Ih, it is better to separate this in several questions. Also, be careful so that it cannot be taken to the opinionated side.

  • I thought of separating but leaving this type of content in one place only helps in search of later, and on the opinions, I think I went straight, I did not ask which is better than the other.

1 answer

6


The 3 are different things that can be understood as a pool of solutions that used together can solve architecture and scalability problems for applications that need a great performance (when they have many simultaneous accesses, constant search, Realtime, etc).

Redis you can use for various purposes as inter-process communication (imagine that you have a system that is part Node.js, Java and PHP, and you need to communicate all this, the redis would help in this, with the Pub/Sub https://redis.io/topics/pubsub), leave the data in RAM for faster access, and it replicates on disk for persistence in case of restarting the server for example, value key and lists (including range option). No doubt Redis is a very complete solution that we can use to solve many architecture problems.

In the case of Elasticsearch, the idea is not to store data, but to SEARCH data. Elasticsearch and Solr were developed on top of the Lucene, where the idea is to organize files. Imagine that in this context, you can save only properties and indexes that you would like to use for searches.

Now let’s go to a real-world application where you need performance using Redis, Elasticsearch and a relational database.

You load the lines of a given table of your RDB that has a large volume of search in Redis using value key (id=>line of data in JSON), you load Elasticsearch with the properties including for geolocation search. When the user accesses your site / webservice, you do the search using Elasticsearch and returns the indexes, which you will use to retrieve the data in redis, which is loaded in RAM. Try to imagine this working in an environment that actually has many simultaneous accesses.

When the user updates some information, replicate it in Elasticsearch and Redis.

Remembering that this is just one example of the thousands of things that can be done.

I hope I’ve helped you understand.

  • Helped yes, but another thing I saw on the net was them using Elastic as a database and so leaving to use a relational or other non-relational like Mongo, so I saw from Redis this is not a good practice but the same applies to Elastic?

  • 2

    So @João doesn’t have a silver bullet for everything in software architecture, it’s hard to say it’s wrong, because I don’t know the context applied of who’s using it for storage, but if you look at Elasticsearch’s own website, they call themselves as a search engine. The "normal" is to use focusing on the search. In the case of Redis is the same thing, I do not use redis to "store" (well between quotes even, because when you are storing the data, you are storing), I use for caching and communication between processes in some cases.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.