When to use Redis instead of MySQL for PHP applications?

I looked at Radish. It looks very interesting. But from a practical point of view, in what cases would it be better to use Redis over MySQL?

+61
php mysql redis
Oct 19 '10 at 8:53
source share
5 answers

Ignoring the NoSQL vs. SQL debate, I think the best approach is to combine them. In other words, use MySQL for for some parts of the system (complex searches, transactions) and redis for others (performance, counters, etc.).

In my experience, performance issues related to scalability (many users ...) ultimately force you to add some kind of cache to take the load off the MySQL server, and redis / memcached is very good at that.

+78
Oct. 19 '10 at 9:39
source share

I'm not an expert on Redis, but from what I have compiled, both are quite different. Redis:

  • It is not a relational database (no fancy data organization).
  • Saves everything in memory (faster, less space, maybe less safe in case of failure)
  • Less commonly used on different web hosts (unless you accept yourself)

I think that you can use Redis for those cases when you have a small amount of data that does not need the relational structure that MySQL offers and requires quick access. This can be, for example, session data in a dynamic web interface, which must be accessed frequently and quickly.

Redis can also be used as a cache for some MySQL data that it will access very often (i.e., load it when the user logs in).

I think that you are asking the question incorrectly, you should ask yourself which one is more suitable for the application, and not which application is suitable for the system;)

+20
Oct 19 '10 at 9:16
source share

MySQL is a relational data warehouse. If configured (for example, using innodb tables), MySQL is a reliable data warehouse that offers ACID transactions.

Redis is a NoSQL database. This is faster (if used correctly) because it trades speed with reliability (rarely performed using fsync, as this drastically degrades performance) and transactions (which can be approximated - slowly - with SETNX ).

Redis has some very neat features , such as sets, lists, and sorted lists.

These slides at Redis list statistics collection and session management as examples. There is also a twitter clone written using redis as an example, but this does not mean that Twitter uses redis ( using MySQL twitter with heavy memcache caching).

+12
19 Oct. '10 at 9:24
source share

MySql -

1) Structured data 2) ACID 3) Heavy transactions and searches.

Redis -

1) Unstructured data 2) Simple and quick search. e.g. - session token 3) use it for the cache layer.

+6
Dec 08 '15 at 20:47
source share

According to the official website, Redis is an open source in-memory data structure repository (licensed by BSD) that is used as a database, cache, and message broker. In fact, Redis is an extended keystore. This is literally super fast with surprisingly high throughput, as it can perform approximately 110,000 SET operations per second, about 81,000 GET operations per second. It also supports a very rich set of data types for storage. In fact, Redis stores data in memory each time, as well as a permanent database on disk. So, this comes with a trade-off: amazing speed with a size limit for datasets (according to memory). In this article, in order to have some tests compared to MySQL, we will use Redis only as a caching mechanism.

Read here: Redis vs MySQL Benchmarks

0
Apr 13 '19 at 6:36
source share



All Articles