Submit your project
Get a free quote
Make your app run faster with Redis
With faster operations, your entire business generates more revenue and less friction. For every application you use in your company, improving the search results or database queries response time impacts all your services: sales and business development, human resources, customer relationship, production, or design.
In our story, we will introduce you to Redis and show you how we implement it to improve our application's API performance, and we have created a demo to try out.
Introduction to Redis
Redis is an in-memory database. It relies on a computer's RAM instead of disk drives, which offers a faster response time than a physical drive because reading data from memory is way faster. Redis is an in-memory data store to ingest, process, and analyze real-time data with sub-millisecond latency. Redis is an ideal choice for searching, ad targeting, personalization, IoT, and others. It is language agnostic; you can use any programming language you're specialized in.
The performance result from Redis is noticeable when your system has a large dataset. It benefits application scalability when it gets more and more users, resulting in more and more data being requested or responded to. It is also a way to avoid database bottlenecks and cache the result of complex, time-consuming database queries to retrieve it faster for future requests.
Who's using Redis?
Redis's official website state that Redis is trusted and used by many large corporations. Many famous companies adopt Redis to their production environments, such as Instagram, Github, Airbnb, Twitter, and Stackoverflow.
Redis launched in 2009, and over many years, it has proven itself in a wide range of projects or companies to be a fast, credible, reliable, and efficient solution. That's why you should give it a try too!
Use Cases
As mentioned before, we can thoughtfully implement the Redis solution into many kinds of use cases thanks to its wide variety of data structures which will meet your application requirements.
Redis can cache data, build chat and messaging, maintain queues, create real-time leaderboards, store sessions, stream rich media, cache geospatial, and serve machine learning and real-time analytics.
Talentiva Demo
In this story, we have created a demo to showcase Redis caching feature, which we use to improve our API response.
*Contact us to try our demo.
Here's Talentiva, a talent database that contains many personal profiles for professional career searching. We added profile attributes like country of birth, current country, skills, and languages to add more complexity. Users can search on different criteria to get different results based on their requests.
We made it by using the following:
- NextJS (Server-rendered React framework),
- ExpressJS (Define and maintain business logic and then serve an API), and
- MongoDB (Database to store all data).
The flow without Redis would look like this:
- The user sends a request to the server using the search field on the search page;
- The backend side application takes the submitted criteria queried on the database;
- MongoDB aggregation operation will process a query with multiple documents or collections and return computed results;
- The server sends back the result to the client.
The problem is that a client sends a request to query data from the database every single time.
If different users send the same request many times, the database must process and respond with the same data. It would not be a cost-effective solution. If your dataset is large, it will slow down the process!
Redis Solution
Now it's time to use the Redis cache to improve the process. We have installed a Redis instance and then written a function on the server-side application to determine whether a query has been requested before and the responded data is already in the Redis cache.
Suppose the data is in the Redis cache. Just responding that data to the client directly saves time as time spent getting data on Redis is much less.
Suppose the data is not in the Redis cache. Then, query it from the database, save the result in the Redis cache, and respond to the client.
You can see from our demo that if you search with the same criteria. The second time, Redis enables a much shorter response time.
As you can see clearly from the image and chart above, the response from Redis Cache is much faster compared to the response from the database.
Questions
No, you don't need to change your server infrastructure. You can use it with your current server and your wep/app.
Memcached is made for simplicity while Redis can offer wide range of features. We can say that Redis is much more powerful than Memcached. That's why we suggest Redis.
It depends on your web/app, contact us if you want to get a more personalized answer.
Conclusion
Redis can cache the data to avoid running the same queries on the database within an unchanged dataset/result. This solution will save unneeded database requests. Additionally, Redis caching is not the only solution from Redis to improve application performance. There are many solutions that Redis can offer depending on the problem that you would like to solve.
Also, things can get more complex when we want to maintain the consistency between the database and Redis Cache. It could be challenging to implement, such as invalidation when the dataset is updated, or problematic if implemented incorrectly. Therefore some areas will require experts who have experiences and knowledge to work on.
We have heard that "there are no single solutions that solve all problems." It is also true for software development. If you have your business problem/idea, you wish to use technology to solve/make it come true. You are always welcome to consult with QPS. We are an experienced Digital Solutions Agency with 15+ years of experience in this industry. Don't hesitate to tell us about your project, consult us with your problem, or request a quote; It is free of charge!