5

I would like to ask you as experts about PHP, ASP.NET/C#, Python or any other server side language.

How do they span multiple servers? When I see a big website and look how many dedicated servers it uses, at least it uses 10 servers. I sit and think how the langauge that was used in building this site span these servers? Is there something in the language itself or its architecture that make it able to go with this and is there some language that are better than others regarding this?

Edit: But I see many ASP.NET and PHP powered sites that are on many servers, in this case how can the same programmed site be on server 1, on server 2, etc. Does Server 1 contain some functionality for example and Server 2 contain others? Or do they just progrm the site and the hosting company makes balance between these servers?

2
  • The hard part is if they need to access and update common data.
    – user1249
    Commented Aug 5, 2011 at 11:43
  • I'm wondering if this would be better on serverfault.com where there might be more people with better and more detailed answers...? Commented Aug 5, 2011 at 13:52

4 Answers 4

7

Generally speaking, the language doesn't have a concept of multiple servers. It works in isolation on its server. The fact there are multiple instances is not generally considered at the language level.

It is a bit like checkout staff in a super market, they each do their job. They don't need to consider if there are other staff or interact with them.

The question of how to route traffic/customers to different machines is in the architecture.

Edit to Address your revised Question:

You are now asking a much bigger question. There is no 1 fit answer, however let me give you a common setup example with php.

Lets say we have a php website which needs to allow a login function and a view rss feeds function.

We could have all the servers as general php - and they all perform login and rss viewing.

Alternativly, we could assign 5 servers for login and 5 for viewing.

There are a billion questions/issues that help us decide how to divide the architecture.

In the example above, it would be common for the login to be done via HTTPS - but the RSS viewing not to be done via HTTPS.

HTTPS servers have a higher resource usage than non, so it may well make sense to split HTTPS functions (login) away from HTTP (view rss)

Additionally, splitting static content e.g. CSS files, images away from PHP is often worthwhile. You can configure servers to be very good at serving static files while leaving your php servers primed for php.

We now have a scenario with a group of servers that handle HTTPS logins, HTTP viewing and a third group that hosts our css, images, javascript, etc.

There is a lot more on this topic, but there is plenty of material to read - google for scaling up applications or look for talks from facebook etc, who give out info on how they do this (to some level).

4

The keyword is load-balancing here. Some languages like Java offer special support for it. A good multi-part introduction from a Java point-of-view can be found here.

1
  • Java itself does not offer load balancing as part of the language; its provided as part of the server platform.
    – Ken Liu
    Commented Dec 8, 2013 at 20:19
3

Building such sites is in essence distributed programming, and one of the few languages that support this as a core concept is Erlang.

2

There are several basic ways this is done, none of them require special support at the language level:

1) All servers can do everything that needs to be done. A user is assigned to a server randomly, based on the server closest to him netwise, or based on load. Each server just does its job without caring that a bunch of other servers are doing the same thing. The servers may access a common database.

2) Servers do completely different jobs. One server may hold static images. Another server may hold RSS feeds. Another server might store account information. A web page may contain assembled bits and pieces from many different servers and submit a form to yet some other server. Another server might handle email.

3) Servers do the same type of job, but divide the task space. For example, a news site might have five web servers, one for international news, one for local news, one for weather, and so on.

4) Servers use an assembly line approach. A front end server might receive web requests, confirm that they are valid, and pick a second-level server. The second-level server might log the request and figure out which third-level server handles the data the user is after. The third-level server assembles the data, possibly using a database, and hands it back to the second-level server. The second-level server builds the HTML or XML or whatever the user requires and passes it back to the first-level server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.