When to use Redis instead of MySQL for PHP applications?

Viewed 58721

I've been looking at Redis. It looks very interesting. But from a practical perspective, in what cases would it be better to use Redis over MySQL?

6 Answers

Redis, SQL (+NoSQL) have their benefits+drawbacks and often live side by side:

  • Redis - Local variables moved to a separate application
    • Easy to move from local variables/prototype
    • Persistant storrage
    • Multiple users/applications all see the same data
    • Scalability
    • Failover
    • (-) Hard to do more advanced queries/questions on the data
  • NoSQL
    • Dump raw data into the "database"
    • All/most of Redis features
    • (-) Harder to do advanced queries, compared to SQL
  • SQL
    • Advanced queries between data
    • All/most of Redis features
    • (-) Need to place data into "schema" (think sheet/Excel)
    • (-) Bit harder to get simple values in/out than Redis/NoSQL

(different SQL/NoSQL solutions can vary. You should read up on CAP theorem and ACID on why one system can't simultaneously give you all)

According to the official website, Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. Actually, Redis is an advanced key-value store. It is literally super fast with amazingly high throughput as it can perform approximately 110000 SETs per second, about 81000 GETs per second. It also supports a very rich set of data types to store. As a matter of fact, Redis keeps the data in-memory every time but also persistent on-disk database. So, it comes with a trade-off: Amazing speed with the size limit on datasets (as per memory). In this article, to have some benchmarks in comparison to MySQL, we would be using Redis as a caching engine only.

Read Here: Redis vs MySQL Benchmarks

Related