There is one social project.
Users can subscribe to site categories. Let's say on the article. If an article is added to the database ( Insert Mysq l), then a real time message about the new article added to all subscribed clients is sent. There is also a Like function like on facebook .

Accordingly, we need the speed of all these processes .. Who, what can be said, starting from the question of which database and what is better to use and how should it be right?

  • I would choose among mongoDB or MySQL. redis a little for another, but they do on it. I would take what I know better. - KoVadim
  • one
    I am more confused by the question of selecting the database in relation to the situation. In this particular case, the question of the architecture of the application that will serve the customers is much more important than the database. - SilverIce
  • I will be glad to any comments and tips and architecture ... - IOleg
  • one
    It is not necessary to choose one thing. From Redis you can take a pub / sub system, i.e. make notifications, store sessions there. In Mongo, you can store articles and user profiles. - Zamony 4:21 pm
  • Real time via HTTP? Monsieur knows a lot about perversions. Take any convenient base, the speed of work with the base is still higher than the network speed. - VladD

1 answer 1

Do you want to use only one database as storage? In modern projects, to solve similar problems, all three bases can be used simultaneously. MySQL (and increasingly PosgreSQL) is used to store data in a normalized form and perform transactions. If you do not need transactions, you can safely refuse a classic DBMS tied to a hard disk.

MongoDB is attractive as a document repository, since you have articles, you can store them in a denormalized form directly in MongoDB, and due to the fact that it is located in RAM, quickly give them to clients. Good horizontal scalability will allow you to quickly increase the power of your cluster with the growing popularity of the project.

Redis is attractive with the built-in Pub / Sub-mechanism, however, you need to be very careful with it, as it is single-threaded. In case you have one Redis instance running and some lengthy operations are performed on it, a queue of requests will accumulate (sometimes significant). However, it also scales well, is clustered and can withstand an incredible amount of simultaneous connections.

Ps. If I had your task and I was limited to only one of the three databases, I would focus on MongoDB: it allows you to store data in the form of finished documents on the one hand, on the other, it allows you to build up to 64 indexes on a collection, allowing you to bring speed sampling to incredible values ​​(which you most likely will never see on MySQL). Redis, although it allows storage of several data types, is still convenient as a cache, it is not always convenient to store difficult-structured data (text, keywords, authors, etc.) in it.