1
00:00:00,070 --> 00:00:06,370
In this session we are going to learn about Benchmarking Performance. So since

2
00:00:06,370 --> 00:00:08,760
we have already installed Redis on one of the machine.

3
00:00:08,980 --> 00:00:13,330
So we will see what is the, you know, Read and Write performance which we are going to achieve.

4
00:00:16,000 --> 00:00:18,260
And I will let you know how we are going to do that.

5
00:00:19,020 --> 00:00:19,380
Okay.

6
00:00:19,400 --> 00:00:24,870
So before that what I have done is, I have logged into a machine. So I have closed previous sessions and

7
00:00:24,890 --> 00:00:33,460
I have opened a new session now and currently I am in /home/redisadmin  directory.

8
00:00:33,630 --> 00:00:40,540
So as you know to connect to rediscli, you need to type redis-cli

9
00:00:40,590 --> 00:00:49,650
and since we have installed Redis server on Port 6 3 7 0. We also need to pass port explicitly by

10
00:00:49,650 --> 00:00:53,700
specifying-p.

11
00:00:54,290 --> 00:00:58,400
So once I do that I should be able to log into Redis server.

12
00:00:58,760 --> 00:01:00,260
So what do you think?

13
00:01:00,470 --> 00:01:03,670
Will I be able to log in to Redis Server?

14
00:01:03,680 --> 00:01:05,610
Or will I be able to connect or not?

15
00:01:05,630 --> 00:01:06,320
Let's check that.

16
00:01:07,910 --> 00:01:11,630
So as you see again I have, I'm getting the error that Rediscli is not found.

17
00:01:12,110 --> 00:01:12,460
OK.

18
00:01:12,470 --> 00:01:16,300
As I told you in previous session that our Redis

19
00:01:16,310 --> 00:01:22,650
Utilities are under, you know, here under src directory.

20
00:01:22,720 --> 00:01:25,250
So in the previous session, we had also set up the path.

21
00:01:25,410 --> 00:01:25,700
OK.

22
00:01:25,710 --> 00:01:32,650
And then we were able to run Redis-server or Redis-cli or  any utility, which is under src

23
00:01:32,710 --> 00:01:41,870
directory. We were able to run that utilities from anywhere but now what has happened is since that command,

24
00:01:41,910 --> 00:01:44,550
which we ran that is only in session specific.

25
00:01:44,940 --> 00:01:45,230
OK.

26
00:01:45,240 --> 00:01:51,760
So that path variable which we had set up that was only in session specific.

27
00:01:51,780 --> 00:01:55,530
So when I closed that session and I opened a new session.

28
00:01:56,100 --> 00:02:01,680
So whatever changes which were there, has actually gone because that was session specific.

29
00:02:01,710 --> 00:02:06,960
So in this kind of situation what you need to do is, if you want to make that permanent, you actually go

30
00:02:06,960 --> 00:02:09,170
to your Home Directory.

31
00:02:09,180 --> 00:02:14,060
So the way to do that is cd space ~  and press enter.

32
00:02:14,070 --> 00:02:17,070
So you'll be going back to your user's Home Directory.

33
00:02:17,190 --> 00:02:25,160
Now here if you're using bash, you'll be having something  like bash_profile.

34
00:02:30,530 --> 00:02:41,590
it is not .bash-profile, it is .bash_profile. OK, you see I have this file which

35
00:02:41,590 --> 00:02:42,270
actually exist.

36
00:02:42,940 --> 00:02:47,660
So whenever you log into a server, any or  using a bash cell.

37
00:02:47,710 --> 00:02:55,630
So by default as soon as you log in, whatever is inside this file, an Operating System executes whatever

38
00:02:55,630 --> 00:02:58,370
the command which you have put inside this file.

39
00:02:58,990 --> 00:03:00,250
So what I will do is,

40
00:03:06,210 --> 00:03:09,810
whatever command which we had ran previously, I will put that here.

41
00:03:11,020 --> 00:03:11,300
OK.

42
00:03:11,320 --> 00:03:12,790
So if you remember we had put

43
00:03:17,780 --> 00:03:26,070
export PATH=$PATH  and then we had put the complete path of until the source directory

44
00:03:26,090 --> 00:03:35,950
So it was /home/redisadmin/redis-stable/src

45
00:03:44,950 --> 00:03:45,220
OK.

46
00:03:45,240 --> 00:03:48,420
So I'm not going to make any other changes. I have just added this line.

47
00:03:50,760 --> 00:03:51,990
Now what it does is.

48
00:03:52,020 --> 00:03:53,250
So when I log into

49
00:03:55,930 --> 00:04:01,800
when basically I log into this user again,  using any other Session than those a piece of code

50
00:04:01,800 --> 00:04:05,610
which I put under .bash profile, that is going to be executed first.

51
00:04:06,510 --> 00:04:12,330
So when I log in I'm going to feel like you know that the command has already been executed and I'll

52
00:04:12,330 --> 00:04:14,690
be able to run Redis-server or Redis-cli utility directly.

53
00:04:14,700 --> 00:04:23,450
So let's do that. Let's open a new shell.

54
00:04:23,930 --> 00:04:26,600
So I'm going to Right Click and  going to Duplicate Session.

55
00:04:32,240 --> 00:04:32,620
okay.

56
00:04:32,640 --> 00:04:40,590
By default I'm logged in with some other user.  So, I will switch to the user, using which we have installed

57
00:04:40,600 --> 00:04:41,010
Redis

58
00:04:46,890 --> 00:04:47,230
okay.

59
00:04:47,240 --> 00:04:51,560
Right now you can see I am into /home/redisadmin directory.

60
00:04:51,560 --> 00:04:57,060
Now if I do redis-cli-p 6 3 7 0.

61
00:04:58,290 --> 00:05:02,660
So now I am successfully able to connect to Redis server.

62
00:05:02,700 --> 00:05:07,100
So now you know how to make your, you know whatever command you are running.

63
00:05:07,100 --> 00:05:11,610
If you want to, if you put that into a .bash profile, that is going to be the first thing which

64
00:05:11,610 --> 00:05:18,870
is going to be executed and then so basically whatever path you want to set you can put that there and

65
00:05:18,870 --> 00:05:23,040
then that is going to be the first thing which is going to run and you will be able to run all the other

66
00:05:23,040 --> 00:05:28,890
utilities, which is inside that path from anywhere or  any directory

67
00:05:32,730 --> 00:05:33,070
okay.

68
00:05:33,080 --> 00:05:35,410
So, let's do  Keys*

69
00:05:35,820 --> 00:05:38,950
So we know these are the things which we have put there.

70
00:05:39,410 --> 00:05:41,810
So I'm just exiting from here.

71
00:05:42,160 --> 00:05:46,430
And yeah the way to do that is Exit and hit enter.

72
00:05:46,430 --> 00:05:48,550
There's no ; required.

73
00:05:54,170 --> 00:05:56,750
So right now we are in to Redis Admin Directory.

74
00:05:56,750 --> 00:06:03,150
So if I go inside redis/stable/src and I do ls-lrt,  you will also

75
00:06:03,150 --> 00:06:03,860
notice

76
00:06:03,860 --> 00:06:05,000
We have something called

77
00:06:08,510 --> 00:06:10,680
redis-benchmark utility.

78
00:06:11,700 --> 00:06:19,090
So this is a utility which you can use to benchmark performance in your environment. So the first thing

79
00:06:19,090 --> 00:06:26,440
is you install  Redis in the way which is going to be, you know, like production like and then you can run this Redis-

80
00:06:26,460 --> 00:06:28,900
benchmark, to benchmark the performance.

81
00:06:28,960 --> 00:06:37,810
So what it does is, it is going to execute a set of operations. Okay, using some Dummy Data and you can define

82
00:06:37,810 --> 00:06:42,340
the set of operations you want to do or you can define the size of the data which you are going to read

83
00:06:42,340 --> 00:06:48,680
or write and you can also define the number of Records which you want to read or write.

84
00:06:48,830 --> 00:06:53,330
And based on that it will be able to let you know the Performance, which you are going to achieve from

85
00:06:53,330 --> 00:06:54,350
this Redis instance.

86
00:06:56,540 --> 00:06:56,880
OK.

87
00:06:56,890 --> 00:06:57,390
So

88
00:07:00,080 --> 00:07:04,570
let me go to this Documentation.

89
00:07:04,710 --> 00:07:11,270
Now the easiest thing to do is, you can just run Redis benchmark using this command.

90
00:07:20,920 --> 00:07:21,320
okay.

91
00:07:21,340 --> 00:07:21,850
So

92
00:07:30,200 --> 00:07:35,290
okay this is a previous session which which we had opened. So let me close this session.

93
00:07:35,290 --> 00:07:36,840
This is not going to work here.

94
00:07:37,850 --> 00:07:40,430
And yeah, let me come back here.

95
00:07:41,240 --> 00:07:41,640
Okay.

96
00:07:41,680 --> 00:07:42,060
So

97
00:07:46,010 --> 00:07:51,860
what this  going to do is, actually it is going to run Redis benchmark Utility with,in a q mode

98
00:07:51,860 --> 00:07:56,220
And also it is going to pass 100000 records.

99
00:07:56,310 --> 00:08:00,020
And based on that it is going to benchmark the performance ,which we are going to achieve.

100
00:08:00,850 --> 00:08:04,480
So let's  hit enter and let's try to understand what it is does.

101
00:08:04,510 --> 00:08:04,900
All right.

102
00:08:05,100 --> 00:08:06,070
So

103
00:08:06,310 --> 00:08:08,270
right now it has actually given us Connection Refused Error.

104
00:08:08,280 --> 00:08:16,020
The reason being is, that by default this utility also tries to connect to 6 3 7 9

105
00:08:16,020 --> 00:08:17,180
port.

106
00:08:17,490 --> 00:08:23,840
And since we have changed the Port. We should have also passed Port explicitly.

107
00:08:23,930 --> 00:08:29,650
So I'm going to run this command like this.

108
00:08:29,650 --> 00:08:35,050
And also let's say, if you want to pass the host name. You can actually do -h  pass the host

109
00:08:35,050 --> 00:08:37,020
name.

110
00:08:37,090 --> 00:08:44,920
So if your, you know, Redis is running on some other server, you can use  -h  to give the Host Name and

111
00:08:44,920 --> 00:08:54,030
then -p to give the Port Name and then Hit enter. Okay,  so you can see this is running and what

112
00:08:54,030 --> 00:09:00,270
it is doing is, all the set of commands which are available under Ping,  it is actually, which are

113
00:09:00,270 --> 00:09:07,920
actually available under Redis. It is running those commands and trying to show us the, you know, number which

114
00:09:07,920 --> 00:09:08,790
we are achieving

115
00:09:13,780 --> 00:09:17,050
So these are the  different commands which are available in Redis.

116
00:09:17,070 --> 00:09:17,390
OK.

117
00:09:17,420 --> 00:09:23,330
So we can perform Set operation, we can perform Get operation, we can perform Increment operation, we

118
00:09:23,330 --> 00:09:29,260
can perform Left Push operation, we can perform Right Push operation.

119
00:09:29,620 --> 00:09:37,240
So what this utility is doing is, it is running all of these different set of commands and it is running

120
00:09:37,480 --> 00:09:44,840
on 100000 records and then it is telling us the performance which we are going to achieve.

121
00:09:44,870 --> 00:09:46,370
So basically in the Set.

122
00:09:46,370 --> 00:09:47,500
Command or

123
00:09:47,600 --> 00:09:52,100
that is the way to write anything or any Key Value appear in the Redis database.

124
00:09:52,160 --> 00:10:00,070
So we are achieving something around 42000 request per second. Okay.

125
00:10:00,080 --> 00:10:07,270
So again considering the resources which I have, this is very High Performance, which I am able to get.

126
00:10:07,280 --> 00:10:15,950
So just to show you if I run free -h  Command. This is the number of RAM which is available right

127
00:10:15,980 --> 00:10:16,850
now on my machine.

128
00:10:17,150 --> 00:10:17,440
OK.

129
00:10:17,450 --> 00:10:24,830
So you can see this machine is actually having only total 3.5 GB of RAM, out of which

130
00:10:24,830 --> 00:10:29,480
1.9 GB is already used and free is only  548 MB

131
00:10:29,990 --> 00:10:36,410
So if your machine is actually a Production like machine. So you are going to achieve more number of you know,

132
00:10:37,890 --> 00:10:42,210
Reads or Writes or other Operations Performance.

133
00:10:42,240 --> 00:10:50,300
So whenever you install Redis in your environment, you can use Redis benchmark utility to test this. OK.

134
00:10:50,300 --> 00:10:58,820
Now let's say we want to change these parameters and we know that each record or each key value pair

135
00:10:58,820 --> 00:11:02,060
in our case is going to be of N number of Bytes.

136
00:11:02,060 --> 00:11:02,320
OK.

137
00:11:02,350 --> 00:11:04,020
So we can simulate that as well.

138
00:11:06,080 --> 00:11:07,430
So the way to do that is

139
00:11:19,270 --> 00:11:19,600
OK.

140
00:11:19,640 --> 00:11:21,030
So just follow this Document

141
00:11:21,030 --> 00:11:22,830
Actually you'll be able to understand.

142
00:11:23,710 --> 00:11:27,930
Now if I come here and if I see this command Redis-benchmark.

143
00:11:28,340 --> 00:11:33,290
or probably you can go back to, you know, in the beginning and here you can see

144
00:11:36,420 --> 00:11:38,970
there is something called, -d parameter.

145
00:11:38,970 --> 00:11:45,960
And using this I can specify the date size of Set and Get Value in Bytes.

146
00:11:45,960 --> 00:11:52,620
So basically what I am telling is, telling to Redis is that each record is going to be of these many bytes.

147
00:11:53,950 --> 00:11:55,980
OK so let me run this one

148
00:11:58,790 --> 00:12:02,360
and lets say i am telling Redis that each of my record is going to be of

149
00:12:05,380 --> 00:12:06,300
10 bytes.

150
00:12:06,340 --> 00:12:06,570
OK.

151
00:12:06,610 --> 00:12:07,780
So that's the way I do it.

152
00:12:08,350 --> 00:12:17,310
So you specify -d, followed by space and followed by the number of bytes. So 10 is going to be 10 bytes

153
00:12:17,760 --> 00:12:26,190
so by default it runs with 2 bytes. So previous operation which we have ran it, using  default

154
00:12:26,190 --> 00:12:33,660
number. So which means, it was assuming  that the byte or total number of bytes which going to be in each

155
00:12:33,660 --> 00:12:35,190
record is  2 bytes.

156
00:12:35,290 --> 00:12:35,550
Okay.

157
00:12:35,550 --> 00:12:38,580
So now let's run this. Hit enter.

158
00:12:49,540 --> 00:12:49,870
OK.

159
00:12:49,890 --> 00:12:55,680
So basically it is going to run the same way, which it ran  previously and going to show us the

160
00:12:55,680 --> 00:12:56,460
number.

161
00:12:56,460 --> 00:13:01,860
So I do not see any significant change, you know, by changing the number from  2 bytes to 10 bytes, in

162
00:13:01,860 --> 00:13:03,230
my case.

163
00:13:03,330 --> 00:13:10,500
But once you have a real number. Let's say you have a real size of your Key Value Pair. That can be probably

164
00:13:10,500 --> 00:13:15,690
100 bytes and then once you execute with that number you will be able to get the actual benchmarking

165
00:13:17,230 --> 00:13:22,720
and let's assume that we also know the kind of operation we are going to run in Redis.

166
00:13:22,800 --> 00:13:24,260
You know

167
00:13:24,980 --> 00:13:28,140
You are not going to run all of these commands in all the environment.

168
00:13:28,150 --> 00:13:31,660
So probably in most of the  scenarios, you are just going to run Get or  Set.

169
00:13:31,660 --> 00:13:32,830
Command.

170
00:13:32,830 --> 00:13:33,040
OK.

171
00:13:33,040 --> 00:13:38,400
So you are going to write the value to RedisDB and going to read the values from

172
00:13:38,410 --> 00:13:39,210
RedisDB.

173
00:13:39,280 --> 00:13:43,870
So in those case, we don't need to benchmark on all of these operations.

174
00:13:43,870 --> 00:13:49,470
We can actually specify to run only Get or  Set operations.

175
00:13:49,500 --> 00:13:51,090
So now the way to do that is,

176
00:13:58,370 --> 00:14:04,550
so here you see we have something called -t, which specifies a command which you want to run.

177
00:14:04,550 --> 00:14:11,240
So with a , separation you can pass the list of Test Cases which you want to test and then it will

178
00:14:11,240 --> 00:14:13,720
be running only those Test Cases.

179
00:14:13,760 --> 00:14:23,390
So if I go back and if I specify -t and if I type Get,Set so in this case it is only going

180
00:14:23,390 --> 00:14:25,370
to run Get and Set operation.

181
00:14:25,370 --> 00:14:26,390
So let's Hit enter.

182
00:14:32,130 --> 00:14:38,070
and you can see, it ran only Get and Set operations and then it exited because we had specified

183
00:14:38,070 --> 00:14:41,850
to run only Get and Set operations and do the Performance Benchmarking

184
00:14:52,100 --> 00:14:52,410
okay.

185
00:14:52,440 --> 00:15:03,100
So -n basically specify the total number of Requests which you want, to you know, test with.

186
00:15:03,510 --> 00:15:05,010
So by default

187
00:15:05,020 --> 00:15:05,700
or right

188
00:15:05,700 --> 00:15:08,110
now we had actually given 100000

189
00:15:08,160 --> 00:15:12,510
So if you want to test probably on one million record. We can change this value to one million.

190
00:15:15,870 --> 00:15:16,130
OK.

191
00:15:16,210 --> 00:15:18,360
And then this is going to take a bit longer

192
00:15:18,390 --> 00:15:21,750
Because now it has to test one hundred or  i am sorry

193
00:15:21,770 --> 00:15:24,080
now it has to test one million records.

194
00:15:24,930 --> 00:15:32,400
So it is going to, read and write 1 million records in Redis and then going to give us the performance.

195
00:15:32,400 --> 00:15:33,930
So I'm not going to run this now.

196
00:15:33,930 --> 00:15:36,780
I just wanted to show you that if you need, you can do that way.

197
00:15:37,770 --> 00:15:44,400
And also if you know that how many number of Applications or number of Clients, which are going to access

198
00:15:44,550 --> 00:15:52,320
Redis Database, in parallel you can also specify number of expected Clients, by providing -c.

199
00:15:52,920 --> 00:15:59,880
So let's say I know, I know that any point of time there are going to be you know,  maximum of 5 connections

200
00:15:59,910 --> 00:16:03,240
which are going to be run in parallel.

201
00:16:03,510 --> 00:16:09,120
You know those are the 5 connections which are going to perform Read or Write Operations from Redis Database.

202
00:16:09,140 --> 00:16:16,450
So with -c option, I can specify that. Now it is going to create 5 client and then going to

203
00:16:16,600 --> 00:16:20,970
test this. So let's see what is the performance which we achieve

204
00:16:35,020 --> 00:16:35,420
okay.

205
00:16:35,420 --> 00:16:41,380
Actually I had also increase the number of Records which it is  going to test.

206
00:16:41,390 --> 00:16:42,950
So I had changed that to one million.

207
00:16:42,950 --> 00:16:50,810
So now it is performing the test on one million records and with client of 5.

208
00:16:50,820 --> 00:16:56,010
So it is assuming there are 5 parallel clients, which are going to access or perform Read or Write

209
00:16:56,010 --> 00:17:00,750
operations and there are total going to be one million Request.

210
00:17:00,840 --> 00:17:06,300
So it is simulating that and going to tell you the you know, performance which is going to achieve with these

211
00:17:06,300 --> 00:17:07,740
condition.

212
00:17:07,920 --> 00:17:13,940
So you can already see, so probably this time we have not achieved, what we have achieved previously.

213
00:17:14,110 --> 00:17:38,280
We are now only able to achieve somewhere around 38000 you know, Read or Write per second.

214
00:17:38,390 --> 00:17:45,620
Also there is something called -r, which actually specifies the number of random keys which, which

215
00:17:45,740 --> 00:17:47,340
it is going to test.

216
00:17:47,680 --> 00:17:51,020
Redis is going to test this performance with.

217
00:17:57,620 --> 00:18:02,900
so when you specify something like -r 100.

218
00:18:02,950 --> 00:18:08,620
So in this case, even though it is going to perform you know one million queries, which is based on the

219
00:18:08,620 --> 00:18:16,840
value which is specified here after -n, it is actually going to create only 100 Unique Keys and

220
00:18:16,840 --> 00:18:19,750
then it will be performing Read or Write Operations.

221
00:18:20,500 --> 00:18:27,700
So if you want to test, based on let's say 1 million Unique Keys. You can specify those number by providing

222
00:18:27,710 --> 00:18:30,000
-r and the number here.

223
00:18:35,820 --> 00:18:36,040
OK.

224
00:18:36,070 --> 00:18:38,680
So let me test it on a lower value.

225
00:18:38,680 --> 00:18:45,790
I'm just going to probably give only 1000 and here I'm going to be 1000 Unique Keys

226
00:18:48,980 --> 00:18:49,660
OK.

227
00:18:49,720 --> 00:19:01,120
Since the value Set or the Test Set which I given was very smaller. So we got the result very fast.

228
00:19:01,200 --> 00:19:08,340
Now I'm going to connect to Redis, by using  Redis-cli  and i forgot,  I also need to specify

229
00:19:08,340 --> 00:19:08,820
the Port

230
00:19:17,230 --> 00:19:24,020
So guys, again if not required do not change the default Port from 6 3 7 9 to other Ports  because otherwise

231
00:19:24,020 --> 00:19:35,310
you need to specify the Port Number every time.

232
00:19:35,470 --> 00:19:41,290
So now if I do dbsize. It is going to give me the total number of records which are available in database

233
00:19:41,290 --> 00:19:42,500
right now.

234
00:19:42,520 --> 00:19:47,100
So right now we have around 957 Records.

235
00:19:47,260 --> 00:19:52,930
These are the records which got created by all the tests, which we performed and let's say we want

236
00:19:52,930 --> 00:19:54,970
to just flush everything which is there.

237
00:19:55,090 --> 00:19:56,800
So for that one we use Flushall

238
00:19:56,860 --> 00:20:02,100
command.  Please be very careful in, in terms of using this command.

239
00:20:02,100 --> 00:20:06,760
This is going to clean up everything, which is there in Redis database.

240
00:20:07,420 --> 00:20:07,640
OK.

241
00:20:07,660 --> 00:20:10,660
So right now we have 957 Records.

242
00:20:10,810 --> 00:20:17,370
If I do Flushall, it is just going to clear everything. So be very very careful. This is a very destructive

243
00:20:17,370 --> 00:20:20,060
command and it runs very fast.

244
00:20:20,100 --> 00:20:28,560
It just clears up you know, millions of or billions of records in very short time.

245
00:20:28,620 --> 00:20:31,320
So I just ran Flushall. Immediately I got

246
00:20:31,320 --> 00:20:31,890
the output.

247
00:20:31,890 --> 00:20:37,710
Now if I do dbsize. I do not have anything stored in my database

248
00:20:44,260 --> 00:20:44,560
OK.

249
00:20:44,610 --> 00:20:47,880
So once you do the performance testing, you can actually do the cleanup.

250
00:20:48,000 --> 00:20:49,500
So all the test data is removed.
