Você pode ler este post em português também.
Hello! The article of this month will show how is easy to balance the load of an application using your DNS. However, you must be able to do the following actions:
-
Take from your web server the responsibility of storing the session data of your application;
-
To have access to the DNS server that holds the records of your domain;
-
To have more than one web server to holds the requests (obvious, but it’s good to say…).
If your application is written in PHP, you can treat the first item above trough the session_set_save_handler. It’s beyond the scope of this post to show how to do this, but a visit in PHP website will detail the use. The big trick is really on the configuration at DNS server (2nd item). You must configure, to the same A record of your application, the both (or more) IP address which can handle the requests.
The piece of code bellow has been taken from a zone configuration file of a DNS server: ns1 IN A 192.168.0.1 www IN A 192.168.0.2 mta IN A 192.168.0.3 **app IN A 192.168.0.4 app IN A 192.168.0.5**
This feature of balancing the hits of a host to different IP addresses at DNS server could be done via SRV records. The screenshot below shows us (by Apache logs) that both servers are treating the hits. .
The scenario will complicate a little bit more if your application needs to receive data via upload, which will implies in a common place to save the files.
See you ;-)