Now finished up our first little application using Takhar we're now going to start working on our second
application which is going to be a little bit more complicated in nature and it's going to require us
to learn some more advanced features around docker.
Let's first take a look at a mockup of what we're going to build.
All right so here it is.
This is really a classic example of docker in action.
You're going to find a lot of other applications out there that are very similar in nature.
So the purpose of this tiny little application is to make a dock or container that contains a web application
that simply displays inside the browser.
The number of times at this point that someone essentially has visited this server.
And so you can see right now it says number visits 10 that indicates that this page has been visited
10 times.
Now in order to build this we're going to need two separate components.
First off are going to need some type of web server something to actually respond to HTP requests and
generate some H.T. mail to show inside the browser to actually store the number of times that this thing
has been visited.
We're going to also make use of a little red house server.
Remember this is an in-memory data store.
You can essentially think of it as a tiny little database that sits entirely inside of memory.
The only purpose of the server is going to be to contain the number of times that the page has been
visited.
Now something to be aware of here.
Yes we absolutely could store this number of visits inside the node application itself.
That's totally an option.
However just to make the thing a little bit more kind of sufficiently complicated we are going to be
making use of redness.
Now I want to think a little bit about how we're going to generally architecture the sap using Dr. In
your first kind of impression here.
Maybe your first guess might be that we're going to make a single container inside that single container
we can run both our node application and a read is server.
Now don't get me wrong this is totally possible you could take this approach right here.
However if this application ever got popular to any degree it would start to have some issues.
Let me tell you what the issue would be.
Let's imagine that you start getting a lot of traffic to this little somewhat useless web site that
you've put together as you start to get more and more traffic.
You're probably going to want to introduce more web application servers to respond to incoming HTP requests.
And so in order to make additional servers you might create additional instances of your doctor container
that contains both the node application and an instance of red is the issue with this approach is that
every one of these different registers will be completely disconnected from each other.
And so one server one read this instance over here inside this Takhar container might think that the
page has been visited 99 times but then some other rattus instance in another container might think
that its only been visited three times.
So in general we would definitely not want to create multiple instances of a red instance for a single
app.
Instead we would want to have one single instance and then if we need to scale up the web application
itself we could just scale the node server and make additional instances of the notes server.
So essentially what we're going to do is be something that looks older and more like this.
We are going to have separate docker containers for both the node application and the red is server.
Each of the docker containers that holds the node app will connect somehow over to the rattus instance
in a separate container and store the current counter current visit variable inside of a server instead.
Now for the first iteration of this project we're not going to worry about scaling just yet.
So we're really going to be setting up something that looks like this right here.
We've got one docker container that contains our node up and then a second container that has just the
red a server inside of it.
So with that in mind let's take a quick break right here.
We're going come back the next section.
We're going to start writing out the code for our node application.
So quick break and I'll see you in just a minute.