Skip to main content

Optimization of Redis


In this Post, I am going to cover how to optimized REDIS  (recently i was reading this random blog giving more clear insight on what is redis and what the use of it in real world) instances as per our requirement. if you are not aware about REDIS at all, you can refer to my previous post where i have covered


  1. How To install REDIS on Centos/Redhat servers which goes here.
  2. How To Create Multiple instances of REDIS which goes here.
  3. What is the Best Standard method to configure REDIS which goes here.

So, Lets see how to optimize our redis server. few points you need to keep in mind that which are important while doing optimization and we are going to learn more about shortly.



For Freelance Work & Queries Contact me by Email Id support@linuxforeveryone.com


  1. Remove any errors you are seeing under redis logs
  2. Check the amount of cache size your site is using for each port
  3. Set proper eviction policy for redis keys
  4. Set proper kernel Settings to make redis run properly.


1) Disable HugePage for kernel


  • # echo never > /sys/kernel/mm/transparent_hugepage/enabled
  •  Add above line in /etc/rc.local file as well so that after server reboot it should be there,else your optimized value will be vanish.





2) Tcp-backlog


  • echo 511 > /proc/sys/net/core/somaxconn 
    •  add it to your /etc/rc.local as well

     3)Maxmemory 



      •   For Full Page Cache set =  (as per the data you get by running below command + 500 MB)
      •   For session/cache = (as per the data you get by running below command + 200 MB)

      Command :   redis-cli -h [Redis Local IP] -p [redis_port] info | grep "used_memory.*human"


      4) Maxmemory-policy

        • maxmemory-policy allkeys-lru

          5) To avoid background save fail under low memory condition

          • Add 'vm.overcommit_memory = 1' to /etc/sysctl.conf (if not present)
          • Run command "sysctl vm.overcommit_memory=1" as root (if not present)




          Comments

          1. I could not resist commenting. Exceptionally well written!

            ReplyDelete
          2. Excellent, what a web site it is! This website presents helpful data to
            us, keep it up.

            ReplyDelete
          3. Thanks for finally talking about >"Optimization of Redis"
            <Liked it!

            ReplyDelete
            Replies
            1. Yup, thats the idea ! of sharing what I know. Glad you liked it.

              Delete
          4. Wow! This blog looks just like my old one! It's on a
            entirely different subject but it has pretty much the same layout and design.
            Outstanding choice of colors!

            ReplyDelete
            Replies
            1. Thank you :) you can share you old one for me to view if you like.

              Delete
          5. I do believe all of the concepts you've offered to your post.
            They're really convincing and can definitely work.
            Nonetheless, the posts are too brief for novices.
            Could you please prolong them a bit from subsequent time?
            Thanks for the post.

            ReplyDelete
            Replies
            1. Thank you for your input, I will definitely try this from next post :)

              Delete
          6. I don't even know how I ended up here, but
            I thought this post was good. I don't know who you are but
            definitely you are going to a famous blogger if you are not
            already ;) Cheers!

            ReplyDelete
          7. I do trust all of the ideas you have offered for
            your post. They are very convincing and will
            definitely work. Nonetheless, the posts are very brief for novices.
            May you please lengthen them a little from next time?

            Thanks for the post.

            ReplyDelete
          8. Thank you :)
            Its google blog, you can also use it for free :)

            ReplyDelete
          9. There's definately a lot to find out about this issue.
            I really like all the points you have made.

            ReplyDelete
          10. I'm truly enjoying the design and layout of your blog. It's
            a very easy on the eyes which makes it much
            more pleasant for me to come here and visit more often.
            Did you hire out a developer to create your theme? Superb work!

            ReplyDelete
            Replies
            1. Thank you :) nope its Google blog theme, anyone can use it for free :)

              Delete
          11. I have been browsing online greater than 3 hours today, but I never found any attention-grabbing article like yours.
            It is pretty price sufficient for me. In my opinion, if all website owners and bloggers
            made excellent content as you did, the internet
            shall be much more helpful than ever before.

            ReplyDelete
          12. For most up-to-date news you have to pay a visit world wide web and on world-wide-web I found this site
            as a finest web page for newest updates.

            ReplyDelete
          13. Hi, I do think this is an excellent website. I stumbledupon it ;) I will
            come back yet again since I book-marked it. Money and freedom is the best way
            to change, may you be rich and continue to guide others.

            ReplyDelete
          14. In fact when someone doesn't be aware of afterward
            its up to other viewers that they will assist, so here it happens.

            ReplyDelete
          15. I will glad to know how my blog helped you. Thanks :)

            ReplyDelete
          16. It's really a nice and helpful piece of info. I am happy
            that you simply shared this helpful information with us.
            Please stay us up to date like this. Thank you for sharing.

            ReplyDelete
            Replies
            1. Thank you :) You can refer this blog which i was recently reading, it will give some more insight how redis helped someone.

              https://blogs.perficientdigital.com/2018/09/18/using-caching-technology-to-boost-e-commerce-business/

              Delete

          Post a Comment

          Popular posts from this blog

          Solution and Step to fix CVE-2019-5736 Vulnerability - Docker

          Recently a new vulnerability has been discovered in the the internet market having target to Docker services. What is this Vulnerability: In short, Docker service uses another service called as runc which is container run time to spawn and run containers. which simply means if docker task is to create docker images then runc task would be running them and attaching a process to container. So as per the recent discovery by the maintainers of runc, the code of this service was having some bug which can be used by attackers to gain the root level of access of the host machine on which docker containers are running. How it can be Exploited: This vulnerability can be exploited in two ways (1) if the docker images are in use is vulnerable making the containers build from it vulnerable also (2) if somehow attacker got the access of containers and then trying to exploit using the bug present in runc and trying to get root privileges. Solution to Fix Vulnerability: Ce

          How to Generate CSR using Openssl in Linux

          Before Generating CSR ,let see what is Openssl. It is nothing but a core library ,which is used for general purpose in cryptography,it is an open source product which work towards the implementation of SSL and TLS protocols. Talking about openssl, some people called the certificates generated from openssl as "self signed certificate". lets go towards now,creating CSR and private key using openssl command, Just log in to any of your Linux box and run following command as  root user  replacing the required information as per your need . [root@SVR home]#   openssl req -new -newkey  rsa:2048 -nodes -sha256 -out domain_name.csr -keyout domain_name.key -subj "/C=US/ST=state/L=locality/O=organization/OU=organization unit Dept/CN=www.domain.com"  You will get output like : Then check whether ,all the information we have entered ,while creating CSR is proper ,by decoding the CSR from some online tool. First do the cat to the csr file [root@SVR home]#  cat

          Multiple instances of redis

          In the last post I have covered how to install redis server on Centos/Rhel using rpm method and yum method and some troubleshooting skills. In this post i am going to cover how to install and configure redis to run with multiple ports.                                                                           But why we need more ports ? If you have read my earlier post , you already know that by default redis runs on single port 6379, which any one can use it for small website to cache the data. But for heavy website like magento we need to use additional ports along with 6379 to serve different cache from different ports. Like in Magento there is simple cache which is normally stored under /var/cache directory. Then there is Full Page Cache which is stored under /var/full_page_cache and session cache which is stored under /var/session_cache. Note : Discussion about cache/full page cache/session is not under the scope for this document.