One IP for many servers?

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Hello all ,

Title might not be clear so here it is in detail:

How do many websites and online games have one address or maybe ip for their servers that are spread all over the world ?

Can we do the same using B4J ?

And what exactly do we need ?

If they are not having the same IP , how are they managing their scattered content ?

Thanks in advance
 

DonManfred

Expert
Licensed User
Longtime User
See the Documentation of Apache server for example.

In apache you can create virtual-hosts (www.domainY.com) beside your normal web (www.domainX.com). the virtual host-list will be consulted if someone send a request to this server and apache will know where to find the files to deliver to the requesting httprequest.

I dont know whether it is possible with b4j or not
 

Ormente

Member
Licensed User
Longtime User
As Manfred said, on a server an IP can "serve" different sites (called virtual hosts). The "routing" is based on the domain, which is part of the request.

Usually an IP targets ONE machine... but that's not exactly true (think about the IP your ISP assign to you, and the multiple devices you can have on your local network "behind" the public IP).

What you are refering to, i think, is another fact : one domain (and related adresses) can resolve to different IPs. It' quite commonly used for load balancing.
See this page for example.

As for B4X, I have no answer: i'm just starting to explore this world.
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Can something like this help?
Modified a code from Erel post in Creating Proxy thread.
B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
mResp = resp
'Ping a list of IPs
StartMessageLoop 
End Sub

Sub ping _result
'mresp redirect the user to best ping server
Stopmessageloop
End sub
 

sorex

Expert
Licensed User
Longtime User
just check the http header's host value then you know which (website) directory should be used to fetch data.
 

LucaMs

Expert
Licensed User
Longtime User
What exactly are you trying to do?

Do you want to use the same ip address for multiple sites or servers?

I'm not sure of what he needs, but I try to describe a scenario.

Suppose that one day I'll publish my app (this is pure fiction :D).

Suppone also that a unique b4j server will not be enough (too many clients).

I decide to install 2 b4j servers on one or two VPS.

How can I get that:

1) all the clients point to a single IP address;
2) users are "managed from a single DB" or from two DBs, but in a way that users can "communicate" as if there were a single DB and a single B4J server.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Suppone also that a unique b4j server will not be enough (too many clients).
The truth is that it is unlikely that a single server will not be enough. See the performance numbers I posted. A B4J server running on a regular computer can handle 2000+ requests per second.

If a single server is not enough then you need to use a load balancer. The user sends the first request to the load balancer (which you can implement in B4J) and the load balancer redirects the request to one of the other computers.
This is for example how the B4i builders work.
 

LucaMs

Expert
Licensed User
Longtime User
The truth is that it is unlikely that a single server will not be enough. See the performance numbers I posted. A B4J server running on a regular computer can handle 2000+ requests per second.
I knew that tests; it will not be my case, but I saw an online multiplayer card game (like mine SHOULD be :D) which had 85,000 users connected at the same time (at least they claim this).

If a single server is not enough then you need to use a load balancer. The user sends the first request to the load balancer (which you can implement in B4J)
First I have to discover what is a "balancer" :D (I'll search).

Many thanks, Erel
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
I knew that tests; it will not be my case, but I saw an online multiplayer card game (like mine SHOULD be :D) which had 85,000 users connected at the same time (at least they claim this).
Yes I think some applications can have huge connected users at the same time .

Also lets take Whatsapp as an example .
Is it saving and proccessing all users' data on one server ?
 

LucaMs

Expert
Licensed User
Longtime User
Even if there are 85k users connected, it doesn't mean that each one of them sends a request every second.
Yes, I thought to this too... but I cannot know exact values.
Probably I will use a single GREAT B4J server ;)


This is for example how the B4i builders work.
A diagram of how B4i builders work would be VEEERY useful
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
A diagram of how B4i builders work would be VEEERY useful
Each one of the builders sends a "ping" message to the manager every minute.
The manager maintains a list of the active builders based on these pings.

The B4i IDE connects to the manager and receives back the ip address of one of the builders and then works with this builder.

If a builder becomes offline then it will be removed from the list after a few minutes (because it stopped sending pings).
 

somed3v3loper

Well-Known Member
Licensed User
Longtime User
Of course not.
So how is it connected to servers ?
shouldn't it have some redirecting method?

BTW , I have some issue replying to forum posts while using mobile .
I have to touch "reply" twice so message gets quoted to text box .
 
Top