Hosting a single website on multiple servers
Most Web Faction accounts deploy a single server, where all of the account’s applications, database, and files are stored and served from a single web server. In some cases, however, it might be beneficial to operate from two or more servers. This tutorial describes when you might need an extra server, how to put the additional server to work, and how to add one to your account.
Table of content:
- Can a website be hosted on two servers?
- Hosting a web site using round-robin DNS
- How to configure multiple dedicated server hosting using Apache on Ubuntu VPS server
- Multiple web servers behind a single firewall
- How to add an additional server
- What is a server?
Can a website be hosted on two servers?
Website hosting: Hosting your website on a single server?
Yes, you can host a wordpress website on multi servers, but you need load balancing and proper management service for it.
Hosting a web site using round-robin DNS
Typically you can add two DNS records for the same name with two different IP addresses. In theory, customers should get one of two of the IP values, and half your traffic should hit each of your web servers.
- One of your web servers will end up getting more traffic than the other. This is because DNS servers choose all their users and serve just one of the two values to many users.
- If one of your servers goes down, half of the users that would hit it will not be able to get to your suite. There is nothing that will route them to the other web that is still up. This makes your suite twice as fragile as it was with only one server and makes it challenging to be scheduled for downtime and maintenance.
Typically, it is better to get two servers as the same web host and add a load balancer in front of them. Generally, a load balancer only works on a local network; however, it routes traffic to servers depending on whether they are actually up. It also lets you control traffic percentages much better.
With either round-robin DNS or a load balancer, you will have two central things to rn WordPress:
- Your wp-content directory, which stores themes and images
- Your database, which stores users and posts
To use two servers, you will have to set both of them up to utilize a network file system for wp-content and a central database. Another option is to keep up with a single website but put a content delivery network (CDN) in front of it. Typically, a CDN is a set of caching proxy servers designed to be close to your users. A CDN will lower the load on your main server while making your site faster for users. Since there is caching, it is challenging to use this technique with highly dynamic websites.
How to configure multiple dedicated servers using Apache on Ubuntu VPS server
If you want to host multiple websites on a server, then you most probably use Apache’s virtual host files to state which domain account should be served out. Typically, name-based virtual hosts are one of the ways used to resolve site requests. This indicates that when someone views your website, the request will travel to the server, which in turn, will figure out which site’s files to serve based on the subdomain name. Deploying this method, you will host multiple sites on one server with the same single IP address. The table below shows the steps for setting up a virtual host file for each of your domains:
|Make a directory for every site||You will create a directory for every site that you will be hosting within the /var/www folder. You will need to create a path in the configuration file—Sub the domain2.com and domain.com for your domain names.
mkdir -p /var/www/domain.com/public_html
|Set folder permissions||that is chmod -R 755 /var/www|
|Set up an Index Page||Something like “testing for domain.com” can be set within this file.|
|Copy the config File for every site||Copy the default configuration file for every site; this will also ensure that you always have a default copy for future site creation.|
|Edit the config file for each site||At the bare minimum, you will adjust and add the highlighted lines within the VirtualHost|
|Verify apache configurations||After starting Apache, and configuring your router you now can view if the configurations are working by either editing your host file on your PC or by editing your domain’s DNS (name servers).|
Another way to host a single website on multiple servers is by using nginx to load balancers. With this type of system, your load balancer can check what is the most available virtual server and send the request there. So it won’t send a request to a server that is down. At the same time, you can configure it to avoid sending requests to a server that is busy.
Typically some hosting providers offer routable IP addresses (failover IP); that way, you can set up different servers prepared to use the same routable public IP address (additional to their static primary IP). To keep both servers synced, you might use a network file system such as drbd or DB replication. When the main server goes down, you can automatically reroute the domain’s IP address to the secondary server. This will possibly not be provided by your provider in mind, but it is the only solution I know that works with multiple servers. Failsafe load balancing requires three servers at least.
Multiple web servers behind a single firewall
There may be times when you require multiple web servers, but you have been given only one Public IP Address. The problem you will run into is that you want to have your multiple domains resolve to the same IP address; however, point to a different server. This is very doable with Apache. You can configure a gateway server within your private cloud server with an address of 192.168.1.2. On your Gateway server, you can install Apache and the mod_proxy files. After this is complete, you will be able to set up the virtual hosts to forward the domain.
How to add an additional server
If you need an additional web server, you can request an additional plan on a different server using the control panel. You can add extra machines as required under a single account; you do not need to begin a new account to make use of more than one server.
To request an additional web server, follow the following steps:
- Log into the WeFaction control panel.
- Click on the account, then add or remove the plan. Click upgrade, downgrade or change your services form will appear.
- Enter your request
- Submit your request
What is a server?
A server is a system or computer that offers data, resources, programs, or services to other computers over a network. Typically most servers are based on X86/X64 CPUs and can run the same code as an X86/X64 desktop computer. Types of servers include Linux/Unix servers, cloud servers, NetWare servers, among others. Some of the best-dedicated hosting and server providers include Godaddy, Liquid web, InMotion Hosting, and HostGator. When shopping for a server, look for a provider who offers good standard features and additional features such as:
- the added benefit of Cloudflare CDN add-on
- access to Cpanel
- data centers in the US and EU
- unlimited bandwidth
- Local MySQL database server
- free SSL certificate to take some hassle off of your costs.