1
00:00:00,720 --> 00:00:04,920
Now finished up our first little application using Takhar we're now going to start working on our second

2
00:00:04,920 --> 00:00:09,300
application which is going to be a little bit more complicated in nature and it's going to require us

3
00:00:09,300 --> 00:00:11,850
to learn some more advanced features around docker.

4
00:00:11,850 --> 00:00:14,790
Let's first take a look at a mockup of what we're going to build.

5
00:00:16,000 --> 00:00:17,120
All right so here it is.

6
00:00:17,170 --> 00:00:20,530
This is really a classic example of docker in action.

7
00:00:20,560 --> 00:00:24,470
You're going to find a lot of other applications out there that are very similar in nature.

8
00:00:24,520 --> 00:00:29,830
So the purpose of this tiny little application is to make a dock or container that contains a web application

9
00:00:30,220 --> 00:00:32,250
that simply displays inside the browser.

10
00:00:32,260 --> 00:00:36,230
The number of times at this point that someone essentially has visited this server.

11
00:00:36,550 --> 00:00:41,470
And so you can see right now it says number visits 10 that indicates that this page has been visited

12
00:00:41,500 --> 00:00:43,010
10 times.

13
00:00:43,120 --> 00:00:47,680
Now in order to build this we're going to need two separate components.

14
00:00:48,080 --> 00:00:53,490
First off are going to need some type of web server something to actually respond to HTP requests and

15
00:00:53,490 --> 00:00:58,750
generate some H.T. mail to show inside the browser to actually store the number of times that this thing

16
00:00:58,750 --> 00:00:59,830
has been visited.

17
00:00:59,830 --> 00:01:03,130
We're going to also make use of a little red house server.

18
00:01:03,370 --> 00:01:05,650
Remember this is an in-memory data store.

19
00:01:05,650 --> 00:01:11,380
You can essentially think of it as a tiny little database that sits entirely inside of memory.

20
00:01:11,590 --> 00:01:16,240
The only purpose of the server is going to be to contain the number of times that the page has been

21
00:01:16,240 --> 00:01:17,300
visited.

22
00:01:17,320 --> 00:01:18,890
Now something to be aware of here.

23
00:01:19,030 --> 00:01:23,810
Yes we absolutely could store this number of visits inside the node application itself.

24
00:01:23,830 --> 00:01:25,210
That's totally an option.

25
00:01:25,210 --> 00:01:29,080
However just to make the thing a little bit more kind of sufficiently complicated we are going to be

26
00:01:29,080 --> 00:01:31,340
making use of redness.

27
00:01:31,390 --> 00:01:37,300
Now I want to think a little bit about how we're going to generally architecture the sap using Dr. In

28
00:01:37,370 --> 00:01:39,120
your first kind of impression here.

29
00:01:39,120 --> 00:01:43,920
Maybe your first guess might be that we're going to make a single container inside that single container

30
00:01:44,160 --> 00:01:47,870
we can run both our node application and a read is server.

31
00:01:48,120 --> 00:01:53,040
Now don't get me wrong this is totally possible you could take this approach right here.

32
00:01:53,040 --> 00:01:58,350
However if this application ever got popular to any degree it would start to have some issues.

33
00:01:58,350 --> 00:02:00,550
Let me tell you what the issue would be.

34
00:02:00,760 --> 00:02:05,510
Let's imagine that you start getting a lot of traffic to this little somewhat useless web site that

35
00:02:05,520 --> 00:02:08,370
you've put together as you start to get more and more traffic.

36
00:02:08,380 --> 00:02:16,030
You're probably going to want to introduce more web application servers to respond to incoming HTP requests.

37
00:02:16,060 --> 00:02:21,100
And so in order to make additional servers you might create additional instances of your doctor container

38
00:02:21,160 --> 00:02:27,490
that contains both the node application and an instance of red is the issue with this approach is that

39
00:02:27,520 --> 00:02:33,530
every one of these different registers will be completely disconnected from each other.

40
00:02:33,640 --> 00:02:39,100
And so one server one read this instance over here inside this Takhar container might think that the

41
00:02:39,100 --> 00:02:45,220
page has been visited 99 times but then some other rattus instance in another container might think

42
00:02:45,220 --> 00:02:47,800
that its only been visited three times.

43
00:02:48,250 --> 00:02:53,920
So in general we would definitely not want to create multiple instances of a red instance for a single

44
00:02:53,920 --> 00:02:54,450
app.

45
00:02:54,610 --> 00:02:59,380
Instead we would want to have one single instance and then if we need to scale up the web application

46
00:02:59,380 --> 00:03:05,230
itself we could just scale the node server and make additional instances of the notes server.

47
00:03:05,230 --> 00:03:09,490
So essentially what we're going to do is be something that looks older and more like this.

48
00:03:09,490 --> 00:03:15,750
We are going to have separate docker containers for both the node application and the red is server.

49
00:03:15,820 --> 00:03:21,730
Each of the docker containers that holds the node app will connect somehow over to the rattus instance

50
00:03:21,790 --> 00:03:29,850
in a separate container and store the current counter current visit variable inside of a server instead.

51
00:03:31,080 --> 00:03:35,370
Now for the first iteration of this project we're not going to worry about scaling just yet.

52
00:03:35,370 --> 00:03:40,060
So we're really going to be setting up something that looks like this right here.

53
00:03:40,260 --> 00:03:45,050
We've got one docker container that contains our node up and then a second container that has just the

54
00:03:45,060 --> 00:03:46,980
red a server inside of it.

55
00:03:46,980 --> 00:03:49,520
So with that in mind let's take a quick break right here.

56
00:03:49,530 --> 00:03:50,760
We're going come back the next section.

57
00:03:50,790 --> 00:03:54,270
We're going to start writing out the code for our node application.

58
00:03:54,310 --> 00:03:56,070
So quick break and I'll see you in just a minute.
