Take A Load Off06 Dec 2019
Computers are a bit like people - there is only so much they can do at once, you don't want to overload them with work, and they are often better at some tasks than others.
When making any modern website or software application we use a team of people to make sure the job is done properly. When running a modern website or software application we use a team of computers so that their job is done properly as well.
The main computer involved with delivering your website to the world is the web server. Every request from a web browser usually goes to that one computer - every page, image, script, pdf document, form and so on. It is very easy to overload a web server. The traditional approach was to make that server more powerful so it can do more things at once, but no matter how powerful you make a computer it will always have a limit. How many times have you needed to upgrade your computer at home or work because everything got slower over time. Even the most expensive, most powerful computer will eventually become slow. The computers that host websites are the same.
The solution is to take as many tasks away from your web server as possible and get specialised computers to do them instead. On my website hosting infrastructure this is how a site is typically set up...
Web Server - The web server creates the pages (HTML) and sends them to each website visitor. Cheap website hosting usually cuts costs by running multiple websites on one web server. This means your website has to share the CPU and RAM with other websites and you all compete with eachother. If you are on the same server as a resource hog (say, a poorly configured or hacked website) then your website suffers. It is like opening lots of apps on a desktop computer - everything eventually slows down. I always use (at least) one web server for each separate website.
Database Server - Relational databases like MySQL need a lot of RAM to combine tables when performing queries. Computers that run code like PHP needs CPU power to execute instructions. That (very simplified explanation) means the optimal configuration you need to efficiently run a database like MySQL is different to what you need to execute code like PHP. Using a separate database server means it can be set up to be faster at databases queries and the web server has more time to answer requests for pages from visitors.
File Server - If all the files and attachments are stored on your web server then it is sending them to visitors as well as the website pages that include them. Moving images and attachments (such as PDF documents) to a separate file server means the web server has more time to make and send web pages. I use Amazon S3 to store website attachments and I serve them through a subdomain. A bonus of using this method is that I can turn file versions on so if a file is ever updated, deleted or hacked then I can restore a previous version.
Form Server - This is an under-appreciated strategy for making a site more reliable while also making it safer if hacked. Traditionally, any contact forms on a website are submitted back to the web server and then an email is sent by the same computer. Moving this to an external server not only takes load off the computer making web pages, but also helps protect from comment spam, blacklisting, and form hijacking.
Image Worker - I have built a few Cloudflare workers to speed up my hosted sites. The most significant one handles image resizing and scaling. This is a task that can be done on your web server but it requires a lot of CPU power and RAM. My Worker task takes that load off the web server and performs cloud-based image manipulation. This makes it easier and faster to create images of any size as required, and caches the results of transformations so future requests for the same modified image are faster.
Social Media Lambda Task - This is my latest cloud-based speed improvement and it has made a significant difference to page load times when social media content is used in a website. Maybe the best feature of TimelineCMS (and its WordPress version) is that content from Facebook, Instagram, YouTube, Pinterest, Twitter and other social media platforms can be used in your website as if it is local website content. The downside used to be that the website needed to fetch that content using the appropriate APIs, perform authentication and security with the social media platform, ensure the content did not get out of date, and avoid being rate limited during busy times. I now have an AWS cloud-based task that is constantly doing this in the background to make sure all TimelineCMS websites are up to date while playing nice with the restrictions placed on them by Facebook, Google and the rest. To see it in action, have a look at https://www.wheatbelt.com.au/ which is fully integrated with two separate Facebook page feeds but has virtually zero load time impact.
Of course all of this is more difficult to set up and configure, and costs a lot more money to run, than simply hosting a website on a single physical or virtual computer. Is it worth it? People demand speed and reliability when browsing. Google uses website speed as a metric when ranking sites against eachother. If you want your website to be loved by visitors and by Google then you really can not afford to cut costs when hosting a website.