How do you create an application like Firebase?

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

But let's say you do something like Firebase. Now on firebase you can create an application and you will get the subdomain <app_name>.firebase.com . Although your server code is still the same for all applications, but requests for app1.firebase.com will be sent to a dedicated set of servers other than app2.firebase.com . Thus, downloading from one application cannot affect another, as it should be.


Like something like Firebase, more specifically, in the interest of limiting the scope of the question, how are requests directed to a specific set of hosts for each application ?

+8
web-applications architecture firebase load-balancing
source share
1 answer

Typically, an β€œapplication”, as you call it, is actually a subdomain or virtual host. This is achieved using several technology stacks.

First you need a DNS record for the subdomain. Thus, app.somedomain.com must have an IP address resolved on the Internet, and an Alias ​​(or A Record) entry is created that points to this subdomain. Once this is completed, you will configure a web server, usually apache or nginx, to handle the subdomain through the so-called virtual host. You should consult the specific documentation for each technology, but for the Apache server its simplest configuration will look something like this:

 <VirtualHost *:80> ServerName app.somedomain.com ServerAdmin webmaster@app.somedomain.com DocumentRoot /var/www/app.somedomain.com/ </VirtualHost> 
+3
source share

All Articles