People clearly asked about mongo, but everyone above answered redis. Redis has the same uses as redis. It is very useful for one-dimensional linear data. However, for data similar to relational data, mongo must be used.
Database: mongodb is still not fast enough, after all, considering persistence. It is recommended that you add a layer of cache, and using redis' ordered collection would be a good choice.
Programmatically, it is implemented through websocket, so that web/iOS/Android can communicate. After the client and server establish a connection, the client sends the message to the server and saves it in redis, and then sends it to the online target friends through the server.
If the other party is offline, cache it in redis. As soon as the other party comes online, the unread messages will be retrieved and sent to the other party
No persistent database will satisfy you in terms of this requirement. You need redis for buffering, or you can even ask redis for persistence (you can search online for specific solutions. I remember Momo’s technical staff did it Overshare)
As for how to store data in mongodb after buffering, it is much easier. You basically only need to consider how to store the data in a reasonable way
People clearly asked about mongo, but everyone above answered redis. Redis has the same uses as redis. It is very useful for one-dimensional linear data. However, for data similar to relational data, mongo must be used.
Database: mongodb is still not fast enough, after all, considering persistence. It is recommended that you add a layer of cache, and using redis' ordered collection would be a good choice.
Programmatically, it is implemented through websocket, so that web/iOS/Android can communicate. After the client and server establish a connection, the client sends the message to the server and saves it in redis, and then sends it to the online target friends through the server.
If the other party is offline, cache it in redis. As soon as the other party comes online, the unread messages will be retrieved and sent to the other party
redis takes the lead and pgsql is the backup. mongodb does this. . . . . It’s still not quite suitable for this scene.
No persistent database will satisfy you in terms of this requirement. You need redis for buffering, or you can even ask redis for persistence (you can search online for specific solutions. I remember Momo’s technical staff did it Overshare)
As for how to store data in mongodb after buffering, it is much easier. You basically only need to consider how to store the data in a reasonable way