Now of course, hosting our website code
is one thing, but what if we also have a database server?
We must not forget that such a database server
is really just that, a standalone server
that's decoupled from our website server
and our website code.
Sure, our website code will often interact
with that database server,
but it's still a standalone server.
And thus far in the course,
no matter if we used MySQL or MongoDB,
we started a fitting server on our local machine
just as we started the website server on our local machine.
You saw code like this where we connect to a database
quite a bit throughout this course.
And here, of course, you might notice that this URL
to which we are connecting
actually does use a different port,
27017 by default for MongoDB,
than our website uses for exposing,
well, our website to the world
or to our local machine right now.
There, we used port 3000 as a default.
Hence, we have two different servers involved.
And thus far, we only learned how we can host websites
and web servers, depending on whether it's a static
or a dynamic website,
but we haven't talked about hosting databases.
We, of course, also wanna host database servers.
And theoretically, just as with websites,
you could rent a machine or build your own machine
and install your database server on it and configure it
such that it's correctly exposed to the world
so that your website server is able to talk to it.
But basically, just as with the website servers
and the machines on which they run,
you wanna avoid building and configuring this on your own
because it's easy to mess something up there
and hard to get it right
and it's easy to introduce security problems
or anything like this.
So therefore, whilst you could rent a remote machine
and install and run a database server on it,
you typically don't wanna do that
because it's difficult to configure in a secure way.
And as your website grows,
you also might run into scaling problems
where at some point your pre-configured
simple database server might be overwhelmed
by the amount of incoming traffic and requests.
Therefore, for databases, we typically also wanna use
dedicated hosting providers,
though the difference here is that we don't just want
a provider that gives us a machine
onto which we can upload our code
because we have no code here.
Instead, we want a provider that gives us
a readily configured database server
that runs somewhere on some remote machine
which is managed by that service provider
so that we don't to care about that at all.
And for MongoDB, MongoDB Atlas is a really amazing,
fully-managed cloud database service,
cloud simply means that it runs on some remote machines
which we don't manage on our own,
and this is an amazing service actually provided by the team
that also works on MongoDB itself.
And it is an amazing service which we will use
throughout this course section.
Right now, you don't have to do anything.
You can read something about it if you want to,
but we'll start using it together
later in this course section.
For the moment, I just want to make you aware of it.
And most importantly,
you should understand why we use such a fully-hosted service
for a database because doing it right on our own
is really, really tricky.