Redis
Redis is a store that keeps data in the computer's memory instead of on a disk, so the same expensive question can be answered instantly the second time.
Also known as in-memory cache key-value store cache server
Definition
Redis is a small, very fast store that sits beside your website and keeps things in memory. Memory is the working space a computer uses while it is on, and reading from it is thousands of times quicker than reading from a disk. That gap is the whole reason Redis exists.
Picture a busy shop page where every visitor asks the same question, which is what is on offer today. Without Redis the site goes to the main database and works the answer out again for every visitor, hundreds of times a minute, for one result. With Redis it works that answer out once and hands the same copy to everyone else for the next minute, so the page arrives quicker. The database is then free for the work only it can do.
It does three more jobs well, starting with remembering who is logged in, so nobody types a password on every click. It also holds a queue of tasks, such as the invoice email that goes out after the sale rather than while the customer waits. And it counts events over short windows, which is how a login form allows five tries a minute and refuses the sixth. That last one is cheap security work that stops most password guessing before it starts.
Here is the part teams learn the hard way, because memory is emptied the moment the machine restarts. Redis can write a copy to disk, but it does that on a schedule, so a restart at the wrong second loses the last few seconds. For a saved page that is fine, and for an order it is not, so nothing whose only copy lives in Redis should matter. The second surprise is that out of the box Redis may use all the memory there is, so when the machine runs out everything on that server suffers. Linkysoft sets that limit on the first day of every project, so ask your supplier what the limit is and what gets thrown away once it is reached.
When Linkysoft builds a web application, Redis usually arrives in the second week, not the first. You cannot save an answer until you know which answers people ask for most, so we measure first, then add it where the measurement points. In a shop system such as Storek the winners are nearly always the same three. They are the category page, the suggestions under the search box, and the basket count in the corner of every screen.
Questions about Redis
Is Redis a database?
Does Redis lose data when the server restarts?
Do I need Redis for a small website?
Is Redis free?
What is the difference between Redis and Memcached?
Still not sure how this applies to your project?
Tell us what you are building and we will answer in plain language.