How to Install Redis on Ubuntu 18.04?

How to setup TensorFlow on Ubuntu

How to setup TensorFlow on Ubuntu

How to setup TensorFlow on Ubuntu - This tutorial will help you set up TensorFlow 1.12 on Ubuntu 16.04 with a GPU using Docker and nvidia-docker.

TensorFlow is one of the most popular deep-learning libraries. It was created by Google and was released as an open-source project in 2015. TensorFlow is used for both research and production environments. Installing TensorFlow can be cumbersome. The difficulty varies based on your environment constraints, and more when you’re a data scientist that just wants to build your neural networks.

When using TensorFlow on GPU — setting up requires a few steps. In the following tutorial, we will go over the process required to set up TensorFlow.


You may also like:5 TensorFlow and ML Courses for Programmers


Requirements:

Step 1 — Prepare your environment with Docker and Nvidia-Docker

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. What exactly is a container? Containers allow data scientists and developers to wrap up an environment with all of the parts it needs — such as libraries and other dependencies — and ship it all out in one package.

To use docker with GPUs and to be able to use TensorFlow in your application, you’ll need to install Docker with Nvidia-Docker. If you already have those installed, move to the next step. Otherwise, you can follow our previous guide to installing nvidia docker.

Prerequisites: Step 2 — Dockerfile

Docker can build images (environments) automatically by reading the instructions from a Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

In our case, those commands will describe the installation of Python 3.6, CUDA 9 and CUDNN 7.2.1 — and of course the installation of TensorFlow 1.12 from source.

For this environment, we will use the following Dockerfile

FROM nvidia/cuda:9.0-base-ubuntu16.04

RUN apt-get update && apt-get install -y --no-install-recommends \
        build-essential \
        cuda-command-line-tools-9-0 \
        cuda-cublas-dev-9-0 \
        cuda-cudart-dev-9-0 \
        cuda-cufft-dev-9-0 \
        cuda-curand-dev-9-0 \
        cuda-cusolver-dev-9-0 \
        cuda-cusparse-dev-9-0 \
        curl \
        git \
        libcudnn7=7.2.1.38-1+cuda9.0 \
        libcudnn7-dev=7.2.1.38-1+cuda9.0 \
	libnccl2=2.4.2-1+cuda9.0 \
	libnccl-dev=2.4.2-1+cuda9.0 \
        libcurl3-dev \
        libfreetype6-dev \
        libhdf5-serial-dev \
        libpng12-dev \
        libzmq3-dev \
        pkg-config \
        rsync \
        software-properties-common \
        unzip \
        zip \
        zlib1g-dev \
        wget \
        && \
    rm -rf /var/lib/apt/lists/* && \
    find /usr/local/cuda-9.0/lib64/ -type f -name 'lib*_static.a' -not -name 'libcudart_static.a' -delete && \
    rm /usr/lib/x86_64-linux-gnu/libcudnn_static_v7.a

# install python 3.6 and pip

RUN apt-get update
RUN apt-get install -y software-properties-common vim
RUN add-apt-repository ppa:jonathonf/python-3.6
RUN apt-get update

RUN apt-get install -y build-essential python3.6 python3.6-dev python3-pip python3.6-venv
RUN apt-get install -y git

RUN apt-get update && \
        apt-get install nvinfer-runtime-trt-repo-ubuntu1604-4.0.1-ga-cuda9.0 && \
        apt-get update && \
        apt-get install libnvinfer4=4.1.2-1+cuda9.0 && \
        apt-get install libnvinfer-dev=4.1.2-1+cuda9.0

RUN python3.6 -m pip install pip --upgrade
RUN python3.6 -m pip install wheel 
RUN python3.6 -m pip install six numpy wheel mock
RUN python3.6 -m pip install keras_applications
RUN python3.6 -m pip install keras_preprocessing

RUN ln -s /usr/bin/python3.6 /usr/bin/python


# Set up Bazel.

# Running bazel inside a `docker build` command causes trouble, cf:
#   https://github.com/bazelbuild/bazel/issues/134
# The easiest solution is to set up a bazelrc file forcing --batch.
RUN echo "startup --batch" >>/etc/bazel.bazelrc
# Similarly, we need to workaround sandboxing issues:
#   https://github.com/bazelbuild/bazel/issues/418
RUN echo "build --spawn_strategy=standalone --genrule_strategy=standalone" \
    >>/etc/bazel.bazelrc
# Install the most recent bazel release.
ENV BAZEL_VERSION 0.15.0
WORKDIR /
RUN mkdir /bazel && \
    cd /bazel && \
    curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
    curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -o /bazel/LICENSE.txt https://raw.githubusercontent.com/bazelbuild/bazel/master/LICENSE && \
    chmod +x bazel-*.sh && \
    ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
    cd / && \
    rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh




# Download and build TensorFlow.
WORKDIR /tensorflow
RUN git clone --branch=r1.12 --depth=1 https://github.com/tensorflow/tensorflow.git .

# Configure the build for our CUDA configuration.
ENV CI_BUILD_PYTHON python3.6
ENV LD_LIBRARY_PATH /usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH
ENV TF_NEED_CUDA 1
ENV TF_NEED_TENSORRT 1
ENV TF_CUDA_COMPUTE_CAPABILITIES=3.5,5.2,6.0,6.1,7.0
ENV TF_CUDA_VERSION=9.0
ENV TF_CUDNN_VERSION=7

RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \
    LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \
    tensorflow/tools/ci_build/builds/configured GPU \
    bazel build -c opt --copt=-mavx --config=cuda \
	--cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" \
        tensorflow/tools/pip_package:build_pip_package && \
    rm /usr/local/cuda/lib64/stubs/libcuda.so.1 && \
    bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/pip && \
    pip --no-cache-dir install --upgrade /tmp/pip/tensorflow-*.whl && \
    rm -rf /tmp/pip && \
    rm -rf /root/.cache
# Clean up pip wheel and Bazel cache when done.

WORKDIR /root

# TensorBoard
EXPOSE 6006

Step 3 — Running Dockerfile

To build the image from the Dockerfile, simply run the docker build command. Keep in mind that this build process might take a few hours to complete. We recommend using nohup utility so that if your terminal hangs — it will still run.

$ docker build -t deeplearning -f Dockerfile

This should output the setup process and should end with something similar to:

>> Successfully built deeplearning (= the image ID)

Your image is ready to use. To start the environment, simply type in the below command. But, don’t forget to replace your image id:

$ docker run --runtime=nvidia -it deeplearning /bin/bashStep 4 — Validating TensorFlow & start building!

Validate that TensorFlow is indeed running in your Dockerfile

$ python
import tensorflow as tf
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
2019-02-23 07:34:14.592926: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports 
instructions that this TensorFlow binary was not compiled to use: AVX2 FMA2019-02-23 07:34:17.452780: I 
tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:964] successful NUMA
node read from SysFS had negative value (-1), but there must be at leastone NUMA node, so returning NUMA node zero
2019-02-23 07:34:17.453267: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with 
properties: 
name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235pciBusID: 0000:00:1e.0
totalMemory: 11.17GiB freeMemory: 11.10GiB
2019-02-23 07:34:17.453306: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu
devices: 0
2019-02-23 07:34:17.772969: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect
StreamExecutor with strength 1 edge matrix:
2019-02-23 07:34:17.773032: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:988]      0
2019-02-23 07:34:17.773054: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0:   N
2019-02-23 07:34:17.773403: I
tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow
device (/job:localhost/replica:0/task:0/device:GPU:0 with 10757 MB memory)
-> physical GPU (device: 0, name: Tesla K80, pci bus id: 0000:00:1e.0,
compute capability: 3.7)
Device mapping:
/job:localhost/replica:0/task:0/device:XLA_CPU:0 -> device: XLA_CPU device
/job:localhost/replica:0/task:0/device:XLA_GPU:0 -> device: XLA_GPU device
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K80,
pci bus id: 0000:00:1e.0, compute capability: 3.7
2019-02-23 07:34:17.774289: I
tensorflow/core/common_runtime/direct_session.cc:307] Device mapping:
/job:localhost/replica:0/task:0/device:XLA_CPU:0 -> device: XLA_CPU device
/job:localhost/replica:0/task:0/device:XLA_GPU:0 -> device: XLA_GPU device
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K80, pci bus id: 0000:0

Congrats! Your new TensorFlow environment is set up and ready to start training, testing and deploying your deep learning models!

Conclusion

Tensorflow has truly disrupted the machine learning world by offering a solution to build production-ready models at scale. But Tensorflow is not always the most user-friendly. It can be difficult to smoothly incorporate into your machine learning pipeline. cnvrg.io data science platform leverages Tensorflow and other open-source tools so that data scientists can focus on the magic — the algorithms. You can find more tutorials on how to easily leverage open-source tools like TensorflowHow to set up Kubernetes for your machine learning workflows, and How to run Spark on Kubernetes. Finding simple ways to integrate these useful tools will get your models closer to production.

Further Reading

How To Set Up Django with Postgres, Nginx, and Gunicorn on Ubuntu 16.04

How To Install Python 3 and Set Up a Programming Environment on Ubuntu 18.04

How To Set Up Jupyter Notebook with Python 3 on Ubuntu 18.04

Originally published by*** *yochze **at towardsdatascience.com


Thanks for reading :heart: If you liked this post, share it with all of your programming buddies! Follow me on Facebook | Twitter

Redis vs MySQL Benchmarks

Redis vs MySQL Benchmarks

In this article, we would be discussing the performance benchmarks of Redis and MySQL. To begin with, we would start with the introduction and installation of Redis over Ubuntu Machine. Then we would move towards the benchmarking between these two.

In this article, we would be discussing the performance benchmarks of Redis and MySQL. To begin with, we would start with the introduction and installation of Redis over Ubuntu Machine. Then we would move towards the benchmarking between these two.

Table of Contents

  • Introduction to Redis
  • Prerequisites
  • Installation of Redis over Ubuntu
Introduction to Redis:

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.

Prerequisites: Installation of Redis over Ubuntu:

In this section, we would be discussing the steps required to install/configure the Redis over ubuntu machine. Here is the stepwise approach for this:

Installation and Configuration of Redis over Ubuntu:

To start with, run the following commands:

 sudo apt update  
 sudo apt install redis-server  

These commands would update the apt package and install the Redis over your Ubuntu machine.

Now, As a matter of fact, to enable Redis being used as a Service, you need to configure it by updating the supervised directive present inside the configuration file of Redis. You can easily find the configuration file here:

 sudo vi /etc/redis/redis.conf  

By default, the supervised directive is set to "no". You need to set it to: systemd . After updating, this section of configuration file would look like something similar to this:

 ################################# GENERAL #####################################  
 # By default Redis does not run as a daemon. Use 'yes' if you need it.  
 # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.  
 daemonize yes  
 # If you run Redis from upstart or systemd, Redis can interact with your  
 # supervision tree. Options:  
 #  supervised no   - no supervision interaction  
 #  supervised upstart - signal upstart by putting Redis into SIGSTOP mode  
 #  supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET  
 #  supervised auto  - detect upstart or systemd method based on  
 #            UPSTART_JOB or NOTIFY_SOCKET environment variables  
 # Note: these supervision methods only signal "process is ready."  
 #    They do not enable continuous liveness pings back to your supervisor.  
 supervised systemd  
 # If a pid file is specified, Redis writes it where specified at startup  
 # and removes it at exit.  
 #  
 # When the server runs non daemonized, no pid file is created if none is  
 # specified in the configuration. When the server is daemonized, the pid file  
 # is used even if not specified, defaulting to "/var/run/redis.pid".  
 #  
 # Creating a pid file is best effort: if Redis is not able to create it  
 # nothing bad happens, the server will start and run normally.  
 pidfile /var/run/redis/redis-server.pid  
 # Specify the server verbosity level.  
 # This can be one of:  
 # debug (a lot of information, useful for development/testing)  
 # verbose (many rarely useful info, but not a mess like the debug level)  
 # notice (moderately verbose, what you want in production probably)  

Save this file now and to have the changes reflected over Redis, restart the Redis Service by using the following command:

 sudo systemctl restart redis.service  

Enabling Password Authentication:

Configuring the Redis with password authentication is not mandatory though, but it is super important (and easy too) as it enables the security factor over Redis. Configuring our Redis server with the password is super easy and can be done through the same configuration file as mentioned above. So, open the configuration file and look for *requirepass *directive. You would that line is commented by default, just uncomment that and enter your password there. The configuration file would look similar to this:

 # Require clients to issue AUTH  before processing any other  
 # commands. This might be useful in environments in which you do not trust  
 # others with access to the host running redis-server.  
 #  
 # This should stay commented out for backward compatibility and because most  
 # people do not need auth (e.g. they run their own servers).  
 #  
 # Warning: since Redis is pretty fast an outside user can try up to  
 # 150k passwords per second against a good box. This means that you should  
 # use a very strong password otherwise it will be very easy to break.  
 requirepass yourpasswordhere  
 # Command renaming.  
 #  
 # It is possible to change the name of dangerous commands in a shared  
 # environment. For instance the CONFIG command may be renamed into something  
 # hard to guess so that it will still be available for internal-use tools  
 # but not available for general clients.  
 #  
 # Example:  
 #  
 # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52  

Save this file now and to have the changes reflected over Redis, restart the Redis Service by using the following command:

 sudo systemctl restart redis.service  

Installation of PHPRedis over Ubuntu:

Now, to enable your PHP code to use Redis as a service:

 sudo apt-get install php-redis  

 extension=redis.so  

Workflow: Source Code:

MySQL Only Source Code :

(When we try to fetch key from MySQL only)

 <?php  
 $con = mysqli_connect("localhost","root","admin","blog_db");  
 for($i = 1; $i <= 10000000; $i = $i *10) {       
      $startTime = microtime(true);  
      for($j = 1; $j <= $i; $j++) {  
           $rand = rand(1, 100000);  
           $sql = "SELECT VALUE from data WHERE `key` = $rand";            
           if (!mysqli_query($con, $sql)) {  
             echo "Error: " . $sql . "" . mysqli_error($con);  
           }  
      }  
 $endTime = microtime(true);  
 file_put_contents('/home/ayush/Desktop/temp/blog/mysqlonly.log', $i . ',' . ($endTime - $startTime) . "\n" , FILE_APPEND);  
 }       

MySQL and Redis Source Code :

(When we try to fetch key from Redis first and then from MySQL if we are unable to find that key on Redis)

 <?php  
 $con = mysqli_connect("localhost","root","admin","blog_db");  
 $client = new Redis();  
 $client->connect('localhost');  
 for($i = 1; $i <= 10000000; $i = $i *10) {  
      $startTime = microtime(true);  
      for($j = 1; $j <= $i; $j++) {  
           $rand = rand(1, 100000);  
           if(!$client->exists($rand)) {  
                $client->set($rand, $rand);  
                $sql = "SELECT VALUE from data WHERE `key` = $rand";            
                if (!mysqli_query($con, $sql)) {  
                  echo "Error: " . $sql . "" . mysqli_error($con);  
                }  
           }   
      }  
      $endTime = microtime(true);  
      file_put_contents('/home/ayush/Desktop/temp/blog/redis.log', $i . ',' . ($endTime - $startTime) . "\n" , FILE_APPEND);  
      $client->flushAll();  
 }       

BenchMarks:

Tabular Data :

Graphical Representation :

Conclusion :

As it can be easily seen from graphical representation given above, as the number of requests increases significantly, Redis starts outperforming by a significant margin. Hence, using a caching engine like Redis along with your database is a good idea if the number of requests processed is huge.

Redis vs. MySQL Benchmarks

Redis vs. MySQL Benchmarks

In this article, we will be discussing the performance benchmarks of Redis and MySQL. To begin with, we will start with the introduction and installation of Redis on an Ubuntu machine. Then we will move towards the benchmarking between these two.

In this article, we will be discussing the performance benchmarks of Redis and MySQL. To begin with, we will start with the introduction and installation of Redis on an Ubuntu machine. Then we will move towards the benchmarking between these two.

Introduction to Redis

According to the official website, Redis is an open source (BSD licensed), in-memory data structure store that’s used as a database, cache, and message broker. Actually, Redis is an advanced key-value store. It is 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 is also a 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.

Prerequisites Installation of Redis on Ubuntu

In this section, we will be discussing the steps required to install/configure Redis on an Ubuntu machine. Here is the approach for this:

Installation and Configuration of Redis on Ubuntu

To start with, run the following commands:

 sudo apt update  
 sudo apt install redis-server  

These commands will update the proper package and install Redis on your Ubuntu machine.

Now, as a matter of fact, to enable Redis to be used as a Service, you need to configure it by updating the supervised directive present inside the configuration file of Redis. You can easily find the configuration file here:

 sudo vi /etc/redis/redis.conf  

By default, the supervised directive is set to “no.” You need to set it to: systemd . After updating, this section of the configuration file will look something like this:

 ################################# GENERAL #####################################  
 # By default Redis does not run as a daemon. Use 'yes' if you need it.  
 # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.  
 daemonize yes  
 # If you run Redis from upstart or systemd, Redis can interact with your  
 # supervision tree. Options:  
 #  supervised no   - no supervision interaction  
 #  supervised upstart - signal upstart by putting Redis into SIGSTOP mode  
 #  supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET  
 #  supervised auto  - detect upstart or systemd method based on  
 #            UPSTART_JOB or NOTIFY_SOCKET environment variables  
 # Note: these supervision methods only signal "process is ready."  
 #    They do not enable continuous liveness pings back to your supervisor.  
 supervised systemd  
 # If a pid file is specified, Redis writes it where specified at startup  
 # and removes it at exit.  
 #  
 # When the server runs non daemonized, no pid file is created if none is  
 # specified in the configuration. When the server is daemonized, the pid file  
 # is used even if not specified, defaulting to "/var/run/redis.pid".  
 #  
 # Creating a pid file is best effort: if Redis is not able to create it  
 # nothing bad happens, the server will start and run normally.  
 pidfile /var/run/redis/redis-server.pid  
 # Specify the server verbosity level.  
 # This can be one of:  
 # debug (a lot of information, useful for development/testing)  
 # verbose (many rarely useful info, but not a mess like the debug level)  
 # notice (moderately verbose, what you want in production probably)  

Save this file and, to have the changes reflected on Redis, restart the Redis Service by using the following command:

 sudo systemctl restart redis.service  

Enabling Password Authentication

Configuring Redis with password authentication is not mandatory, but it is super important (and easy, too) as it enables better security for your Redis instance. Configuring our Redis server with the password is super easy and can be done through the same configuration file as mentioned above. So, open the configuration file and look for the requirepassdirective. You would that line is commented by default, just uncomment it and enter your password there. The configuration file should look similar to this:

 # Require clients to issue AUTH <PASSWORD> before processing any other  
 # commands. This might be useful in environments in which you do not trust  
 # others with access to the host running redis-server.  
 #  
 # This should stay commented out for backward compatibility and because most  
 # people do not need auth (e.g. they run their own servers).  
 #  
 # Warning: since Redis is pretty fast an outside user can try up to  
 # 150k passwords per second against a good box. This means that you should  
 # use a very strong password otherwise it will be very easy to break.  
 requirepass yourpasswordhere  
 # Command renaming.  
 #  
 # It is possible to change the name of dangerous commands in a shared  
 # environment. For instance the CONFIG command may be renamed into something  
 # hard to guess so that it will still be available for internal-use tools  
 # but not available for general clients.  
 #  
 # Example:  
 #  
 # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52  

Save this file and, to have the changes reflected on Redis, restart the Redis Service by using the following command:

 sudo systemctl restart redis.service  

Installation of PHPRedis on Ubuntu

Now, to enable your PHP code to use Redis as a service:

 sudo apt-get install php-redis  

 extension=redis.so  

Workflow Source Code

MySQL Only Source Code

(When we try to fetch a key from MySQL only)

 <?php  
 $con = mysqli_connect("localhost","root","admin","blog_db");  
 for($i = 1; $i <= 10000000; $i = $i *10) {       
      $startTime = microtime(true);  
      for($j = 1; $j <= $i; $j++) {  
           $rand = rand(1, 100000);  
           $sql = "SELECT VALUE from data WHERE `key` = $rand";            
           if (!mysqli_query($con, $sql)) {  
             echo "Error: " . $sql . "" . mysqli_error($con);  
           }  
      }  
 $endTime = microtime(true);  
 file_put_contents('/home/ayush/Desktop/temp/blog/mysqlonly.log', $i . ',' . ($endTime - $startTime) . "\n" , FILE_APPEND);  
 }       

MySQL and Redis Source Code

(When we try to fetch a key from Redis first and then from MySQL if we are unable to find that key on Redis)

 <?php  
 $con = mysqli_connect("localhost","root","admin","blog_db");  
 $client = new Redis();  
 $client->connect('localhost');  
 for($i = 1; $i <= 10000000; $i = $i *10) {  
      $startTime = microtime(true);  
      for($j = 1; $j <= $i; $j++) {  
           $rand = rand(1, 100000);  
           if(!$client->exists($rand)) {  
                $client->set($rand, $rand);  
                $sql = "SELECT VALUE from data WHERE `key` = $rand";            
                if (!mysqli_query($con, $sql)) {  
                  echo "Error: " . $sql . "" . mysqli_error($con);  
                }  
           }   
      }  
      $endTime = microtime(true);  
      file_put_contents('/home/ayush/Desktop/temp/blog/redis.log', $i . ',' . ($endTime - $startTime) . "\n" , FILE_APPEND);  
      $client->flushAll();  
 }       

BenchMarks

Tabular Data

Graphical Representation

Conclusion

As it can be easily seen from graphical representation given above, as the number of requests increases significantly, Redis starts outperforming by a significant margin. Hence, using a caching engine like Redis along with your database is a good idea if the number of requests processed is huge.

Thanks for reading ❤

If you liked this post, share it with all of your programming buddies!