WordPress Cloud Hosting: Shifter Goes Serverless

WordPress Cloud Hosting: A Paradigm Shift in Traditional Hosting

Shifter is a serverless hosting solution for WordPress. It brings serverless technology to one of the most widely used CMS platforms. Here’s how we did it.
shifter

It’s not you, WordPress. It’s everything else.

Over the past 10 years, WordPress has become one of the most successful Open Source projects. Today, one in four websites are powered by WordPress, with no signs of slowing down. WordPress has evolved from a blogging platform into a full content management system. Developers are always discovering new, creative ways to extend and leverage the power of WordPress, from mobile applications to serve the highest trafficked media outlets. There’s not much that WordPress can’t do.

Revisiting Traditional Hosting

First, let’s take a step back and think about where serverless architecture fits in the topic of hosting.

WordPress Cloud hosting is difficult. WordPress is built to serve casual bloggers, enterprise applications, and all users between. However, the same reasons that make it great also make it difficult for both users and hosts. 

Despite the progress made since its release, how we host WordPress has not changed. Deploying, scaling, and security are just more comprehensive versions of what we did 10 years ago.

Now, with WordPress cloud hosting infrastructures just a click away, it’s almost our duty to do more. We revisited the basic needs of hosting to both improve it and to think about it in a completely new way.

Static site generators are a growing trend because they excel at scaling and security while keeping it simple. However, these products tend to fall short in terms of the features and ease of use that you might expect from a full-featured CMS. So, how can we get the best of both worlds? How can we get everything you’d expect from WordPress with the power of static site technology?

WordPress cloud hosting: going Serverless

In many ways, we view our path to serverless hosting as a parallel to the community that realizes a need for the WP REST API.

With the API, developers can abstract the CMS from view. Separating these two functions introduces a whole new set of options. You can now use WordPress to power native applications, Javascript web apps, and more.

We realized that WordPress cloud hosting is no different. Why should we limit ourselves to the monolithic architecture that we grew up with? Why bundle everything into one unhappy server that will always be trying to keep up? To move toward the future, we had to abstract WordPress from the server, which meant going on serverless architecture.

The concept of serverless architecture is about building separate services. On AWS, these services are Lambda, API Gateway, DynamoDB, and Cognito. The tasks of these functions were once performed on servers with various middleware. Because AWS can now deliver these services on-demand or à la carte, there is no need for servers.

Serverless Lifecycle: Creating, Generating, Delivering

Create. Generate. Deliver. This is the life cycle that every website follows, including traditionally hosted websites. With Shifter, we break it down using various microservices in each step.

Creating: Docker

WordPress Cloud Hosting is powered by Docker. This container technology offers a complete filesystem to run everything including WordPress itself. It can quickly boot and varnish. Use it when you need it and delete it when you don’t. Shifter takes advantage of this feature by supplying WordPress when you’re editing content and powers it down when you’re not. With Docker, we can run multiple containers on a server and scale up as demand grows. Shared resources and its impact on speed could potentially be a concern, but they aren’t a factor here. The Docker container running WordPress only has to generate the files we need for use later in the process.
lifecycle

Generating: AWS Microservices

Because our goal is to deliver Shifter as a SaaS, we needed to think about cost, maintenance, and human resources. The AWS suite of microservices, such as Lambda and DynamoDB, allow us to build functions as a service. They fire when needed and can run in parallel. This gives us the freedom to scale. Since WordPress is not bound by server resources, it can pass off the heavy lifting. In turn, this reduces latency and computing power and allows each piece to do what it does best. It ultimately processes dynamic PHP content into static HTML files for deployment.

(function loop(){
  var retry_count = 0;
  var process = require('process');
  process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
  console.log('site_id=' + site_info.id + ', url=' + site_info.url);
  try {
    var req = https.get(site_info.url, function(res) {
      var body = '';
      var status_code = res.statusCode;
      console.log("Got response: %j", status_code);
      if ( status_code == 200 || status_code == 404 ) {
        res.setEncoding('utf8');
        res.on('data', function(chunk) {
          body += chunk;
        });
        res.on('end', function(res) {
          // replace host name
          replaceIndexFileHostname(
            parsedUrl.resource + ( parsedUrl.port ? ':' + parsedUrl.port : '' ),
            site_info.publish,
            body,
            path.join(wk_folder, 'index.html')
          );
          // S3 sync
          s3Sync(
            site_info,
            s3_info,
            {'folder': wk_folder, 'pathname': pathname, 'statusCode': status_code},
            function(err){callbackFunc(err);}
          );
        });
      } else {
        retry_count++;
        if (retry_count > retry_limit) {
          console.log('https response: %j', res);
          callbackFunc(null, "Request response Error: " + res.statusCode);
        } else {
          loop();
        }
      }
    });
    req.setTimeout(60000);
    req.on('timeout', function() {
      console.log('docker url request timed out');
      req.abort();
    });
    req.on('error', function(err) {
      retry_count++;
      if (retry_count > retry_limit) {
        console.log('Error: %j', err);
        callbackFunc(err, 'Request timed out.');
      } else {
        loop();
      }
    });
      req.end();
  } catch (err) {
    console.log('Error: %j', err);
    callbackFunc(err, 'Request timed out.');
  }
})();
Code example: Retrieve HTML file from a Docker machine via HTTPS request, and upload that to S3.

Delivering: S3, CloudFront, Global CDN

Next, static files and resources are moved to a global CDN with all of the inherent security, durability, and speed that you expect. CloudFront delivers content by geolocation. It’s also more secure because there is nothing to maintain. Vulnerability plagued by PHP, Apache, etc. are no longer relevant. This also applies to the database. It’s not there, so there is nothing to hack.

Simply put, it’s a super fast worldwide network of pure content.

Challenges of building a SaaS on new technology with a new concept

Our commitment to going serverless has changed everything for us. We now have the opportunity to offer products alongside much larger companies and still be competitive. AWS gives us, a small startup team, the chance to achieve larger goals with fewer resources, funding, and speed while leveraging more from what we have.

We are happy with the progress that we’ve made, and we are pleased with the capabilities that Shifter offers. We are linking serverless with microservices, which means that we are working in a relatively young development model, especially compared to a traditional LAMP. Of course, we’ll face new problems. And, with this development model, we will find a solution. We believe that this is the right path to follow; that it is the future of hosting. We hope that Shifter will be an example of that future and that it will design for these challenges.
generator
Technical issues aside, the biggest challenge that we face is getting people on board with this approach. Since it’s a new concept, it may be less comfortable and more difficult to understand. We’ll try hard to spread this concept through our product, messaging, and communications.

Kickstarter

We’ve proven that Kickstarter is more than just a wild concept. Today, we need your help to develop our roadmap and bring more features to Shifter. Enter Kickstarter. We will begin our crowdfunding campaign with the opening day of our WordCamp US this year in Philadelphia. We ask for your support to help realize this product and in return, you’ll receive special offers, awesome rewards, first dibs on cool swag, and more.

Avatar

Written by

Hiromichi Koga

Related Posts

Avatar
Jeremy Cook
— September 17, 2019

Cloud Migration Risks & Benefits

If you’re like most businesses, you already have at least one workload running in the cloud. However, that doesn’t mean that cloud migration is right for everyone. While cloud environments are generally scalable, reliable, and highly available, those won’t be the only considerations dri...

Read more
  • AWS
  • Azure
  • Cloud Migration
Joe Nemer
Joe Nemer
— September 12, 2019

Real-Time Application Monitoring with Amazon Kinesis

Amazon Kinesis is a real-time data streaming service that makes it easy to collect, process, and analyze data so you can get quick insights and react as fast as possible to new information.  With Amazon Kinesis you can ingest real-time data such as application logs, website clickstre...

Read more
  • amazon kinesis
  • AWS
  • Stream Analytics
  • Streaming data
Joe Nemer
Joe Nemer
— September 6, 2019

Google Cloud Functions vs. AWS Lambda: The Fight for Serverless Cloud Domination

Serverless computing: What is it and why is it important? A quick background The general concept of serverless computing was introduced to the market by Amazon Web Services (AWS) around 2014 with the release of AWS Lambda. As we know, cloud computing has made it possible for users to ...

Read more
  • AWS
  • Azure
  • Google Cloud Platform
Joe Nemer
Joe Nemer
— September 3, 2019

Google Vision vs. Amazon Rekognition: A Vendor-Neutral Comparison

Google Cloud Vision and Amazon Rekognition offer a broad spectrum of solutions, some of which are comparable in terms of functional details, quality, performance, and costs. This post is a fact-based comparative analysis on Google Vision vs. Amazon Rekognition and will focus on the tech...

Read more
  • Amazon Rekognition
  • AWS
  • Google Cloud Platform
  • Google Vision
Alisha Reyes
Alisha Reyes
— August 30, 2019

New on Cloud Academy: CISSP, AWS, Azure, & DevOps Labs, Python for Beginners, and more…

As Hurricane Dorian intensifies, it looks like Floridians across the entire state might have to hunker down for another big one. If you've gone through a hurricane, you know that preparing for one is no joke. You'll need a survival kit with plenty of water, flashlights, batteries, and n...

Read more
  • AWS
  • Azure
  • Google Cloud Platform
  • New content
  • Product Feature
  • Python programming
Joe Nemer
Joe Nemer
— August 27, 2019

Amazon Route 53: Why You Should Consider DNS Migration

What Amazon Route 53 brings to the DNS table Amazon Route 53 is a highly available and scalable Domain Name System (DNS) service offered by AWS. It is named by the TCP or UDP port 53, which is where DNS server requests are addressed. Like any DNS service, Route 53 handles domain regist...

Read more
  • Amazon
  • AWS
  • Cloud Migration
  • DNS
  • Route 53
Alisha Reyes
Alisha Reyes
— August 22, 2019

How to Unlock Complimentary Access to Cloud Academy

Are you looking to get trained or certified on AWS, Azure, Google Cloud Platform, DevOps, Cloud Security, Python, Java, or another technical skill? Then you'll want to mark your calendars for August 23, 2019. Starting Friday at 12:00 a.m. PDT (3:00 a.m. EDT), Cloud Academy is offering c...

Read more
  • AWS
  • Azure
  • cloud academy content
  • complimentary access
  • GCP
  • on the house
Avatar
Michael Sheehy
— August 19, 2019

What Exactly Is a Cloud Architect and How Do You Become One?

One of the buzzwords surrounding the cloud that I'm sure you've heard is "Cloud Architect." In this article, I will outline my understanding of what a cloud architect does and I'll analyze the skills and certifications necessary to become one. I will also list some of the types of jobs ...

Read more
  • AWS
  • Cloud Computing
Avatar
Nitheesh Poojary
— August 19, 2019

Boto: Using Python to Automate AWS Services

Boto allows you to write scripts to automate things like starting AWS EC2 instances Boto is a Python package that provides programmatic connectivity to Amazon Web Services (AWS). AWS offers a range of services for dynamically scaling servers including the core compute service, Elastic...

Read more
  • Automated AWS Services
  • AWS
  • Boto
  • Python
Avatar
Andrew Larkin
— August 13, 2019

Content Roadmap: AZ-500, ITIL 4, MS-100, Google Cloud Associate Engineer, and More

Last month, Cloud Academy joined forces with QA, the UK’s largest B2B skills provider, and it put us in an excellent position to solve a massive skills gap problem. As a result of this collaboration, you will see our training library grow with additions from QA’s massive catalog of 500+...

Read more
  • AWS
  • Azure
  • content roadmap
  • Google Cloud Platform
Avatar
Adam Hawkins
— August 9, 2019

DevSecOps: How to Secure DevOps Environments

Security has been a friction point when discussing DevOps. This stems from the assumption that DevOps teams move too fast to handle security concerns. This makes sense if Information Security (InfoSec) is separate from the DevOps value stream, or if development velocity exceeds the band...

Read more
  • AWS
  • cloud security
  • DevOps
  • DevSecOps
  • Security
Avatar
Stefano Giacone
— August 8, 2019

Test Your Cloud Knowledge on AWS, Azure, or Google Cloud Platform

Cloud skills are in demand | In today's digital era, employers are constantly seeking skilled professionals with working knowledge of AWS, Azure, and Google Cloud Platform. According to the 2019 Trends in Cloud Transformation report by 451 Research: Business and IT transformations re...

Read more
  • AWS
  • Cloud skills
  • Google Cloud
  • Microsoft Azure