Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you architect an application like Firebase?

Let's say you are making a website (something like Facebook). You write code, deploy it on servers, and increase servers as your load increases. These servers are behind a load-balancer and requests can pretty much go to any server, at random.

But let's say you are making something like Firebase. Now on firebase, you can create an application, and you get a subdomain <app_name>.firebase.com. While your server code is still the same for all the applications, but requests for app1.firebase.com will go to dedicated set of servers, different from app2.firebase.com. So, load from one app, can't affect another, as it should be.


How is something like Firebase designed, more specifically, in the interest of limiting the scope of question, how are requests routed to a particular set of hosts for each application?

like image 466
Jatin Avatar asked Feb 15 '16 11:02

Jatin


1 Answers

Generally, the "app" as you calling it is actually a subdomain or virtual host. This is accomplished via a few technology stacks.

First you need a DNS record fo the subdomain. So app.somedomain.com has to have a IP address that is resolveable on the internet and an Alias record (or A Record) is created that points to that subdomain. Once that is complete you configure a web server, typically apache or nginx to handle the subdomain via what is called a virtual host. You should consult the specific documentation for each technology but for apache server its most basic configuration would look something like this:

<VirtualHost *:80>
   ServerName app.somedomain.com
   ServerAdmin [email protected]
   DocumentRoot /var/www/app.somedomain.com/
</VirtualHost>
like image 64
Griff Avatar answered Nov 07 '22 02:11

Griff