Jazerix
Jazerix

Reputation: 4801

Using Redis as a Notification Service for PHP

I've been looking into creating a notification system in PHP. Much like the one Facebook has got.

The applications is primarily running MySQL for data storage, however MySQL is way to slow for handling something such as notifications.

Here I was thinking Redis, since it's blazingly fast and very simple, and it allow entries to be deleted by themselves after a little while (which is exactly what I want). However I do have so concerns. I read the article Redis Persistence.

As I don't want to lose data and still get a fast experience from Redis, I was wondering what method to use? RDB or AOF or maybe even both? The speed is very important.

So what I'm asking

Upvotes: 1

Views: 950

Answers (1)

Chhavi Gangwal
Chhavi Gangwal

Reputation: 1176

  • Redis is definitely a good choice for your use case
  • Yes you can solely rely on Redis for notifications as you will keep clearing it using expiry mechanism and hence data will remain of reasonable size. Also, my suggestion is to keep notifications associated with the activity id which is actually stored in database. So even in case of any mishap the actual data will be available in MySQL(along with timestamp of its creation).
  • You can use simple php redis client to build this system.
  • RDB in your case should suffice your need as actual activity stream data is anyways being stored in MySQL and data loss is not a very primary concern in such a scenario.

Upvotes: 2

Related Questions