In this post we’ll explore what serverless architecture is and how WordPress sites can benefit from the growing trend.
What is serverless?
Serverless is a misnomer, and servers are still used in serverless architecture, but rather than a fixed server with finite resources, serverless uses a series of microservices triggered by functions to serve up a website or web application.
Hello, hockey-stick growth!
Here’s a snapshot from Google Trends that shows serverless as a growing trend over the past 5 years.
This growth can be attributed to the following benefits that serverless offers:
Event-driven “hosting” aka Saving money and the environment
One of my favorite definitions so far is that a serverless system should be designed with the idea that if nobody is using it, then nothing is running.
This makes it very clear that serverless is “event-driven” as opposed to traditional hosting which runs all the time.
By not having your site run all the time, you can lower your costs and your carbon footprint during “off” times. And let’s remember that data centers have a carbon footprint set to exceed that of the entire aviation industry!
Another aspect of serverless is that unlike traditional hosting, there are no fixed resources.
This translates into not needing to worry about scaling or traffic spikes, because serverless scales automatically with demand and you’d never need to add more server resources ahead of huge press coverage.
With serverless, the attack surface is reduced since there’s no underlying database that can be hacked or processing server that needs to be patched and maintained.
Currently, WordPress sites suffer tremendously from security woe. It’s a prime target for hackers because of its ongoing vulnerabilities (over 70% of WordPress sites have active vulnerabilities) and immense popularity (over 34% of websites are running WordPress).
What to consider before going serverless with WordPress
WordPress is a dynamic CMS which means it queries the database for content. Therefore, by default, WordPress is not compatible with serverless.
In order to go serverless:
- To emulate dynamic (i.e. talking to the database) functionality on your site, you need to either use third-party services and/or recreate the functionality with dynamic scripts (eg. Lambda).
How to take WordPress serverless
Luckily, there are a few ways to turn your website into a static site and take advantage of serverless.
- You can use a WordPress plugin like Simply Static, but there are some inconveniences and limitations you should consider first.
- You can use an all-in-one platform like Strattic (that’s us!), that generates a static version of your WordPress site, and deploys it to serverless. Strattic also comes with a built-in solution for handling dynamic functionality such as contact forms and site search. And..for even more speed and security, the static files are served on a CDN, with HTTP/2. The bottom line is that you get the benefits of serverless, but you can keep using WordPress like you always have.
Serverless, a more flexible hosting solution, has many benefits, including being “on” when needed, scaling on-demand, security, and lower costs.
For a “long” time (in internet time), WordPress couldn’t take advantage of these benefits since it outputs dynamic websites. Luckily, there are several ways to keep using WordPress and reap the rewards of serverless. Or as we like to say, you can have your cake and eat it too 🙂
Tags: dynamic, microserves, performance, scaling, speed, static, WordPress