Nowadays having an infrastructure of machines to serve thousands of customers around the world is much easier and cheaper than it used to be. Thanks to trusted cloud providers, we now have scalable and inexpensive systems that are easy to configure and use. Just consider our premium WordPress plugins, Nelio A/B Testing and Nelio Content, as an example—they both use the “cloud” to support our customers. If you don’t know these two plugins (that’s weird because we talk about them whenever we can), I recommend you take a look at their features—surely you’ll be interested ?
In startups like ours, it does not make any sense to spend thousands of dollars to buy machines (servers, mainly) to create the ad-hoc infrastructures that support our services. For a fraction of the cost we can have scalable and up-to-date systems in the cloud. The best part? If at any given moment we have a peak load in the system, there’s nothing to worry about—the cloud will scale automatically.
If you think creating a system in the cloud is very complicated, well, I can tell you it is simpler than you think. The advent of serverless technologies is helping to bring the “dreaded” cloud to developers, without the need of professional supervision of system administrators.
When we created Nelio A/B in 2013 we used Google Cloud to build the entire infrastructure. Since we were used to working with the Java programming language, Google AppEngine was the perfect choice by newcomers like us at that time. However, things have been evolving a lot and now it is Amazon Web Services that has taken the lead (in my opinion) in simplifying the use of cloud technologies for developers with little experience administering systems.
Today I will briefly explain the cloud technologies we have used to develop the entire system of Nelio Content in the cloud.
Nelio Content Architecture in the Cloud
When we started to create Nelio Content, we had to decide what cloud infrastructure we’d be using: Google‘s or Amazon’s. Keep in mind that staying on Google meant reusing all the knowledge and experience gained by creating Nelio A/B Testing ? But in Nelio we like challenges… and I personally had the feeling that it was time to give Amazon a try ?. In addition, at that time Amazon launched several new technologies that I liked, so I was convinced we we were doing the right thing.
After a couple of months of hard work and reading documentation (by the way, Amazon’s docs are fantastic), the result was the following architecture:
Although it is a quite simplified diagram, you can see that with only 6 components of Amazon Web Services you can build a powerful system in the cloud that supports all our Nelio Content customers—and the number grows every day ?. Let’s briefly see what each component does.
Amazon API Gateway
This is the entry point of our cloud system for Nelio Content—the communication between the Nelio Content WordPress plugin and the Nelio Content cloud system is done through a REST API (yes, the same approach as the famous WordPress REST API). We created this API using Amazon API Gateway, a fully managed service that makes it easy for developers to create, publish, maintain, and monitor APIs.
Creating your API with this Amazon component is easier than putting together an Ikea piece of furniture. There is no need to know how to program, you can do everything with the user interface of the Amazon console. Or you can use use Swagger (as we do) to define the API within as simple YAML file and then upload that file into the API Gateway every time there’s an update (making it also perfect for developers!) ?
Nelio A/B Testing
I was very impressed by the quality of this plugin, how easy it was to set up, and the outstanding support Nelio provides. I highly recommend Nelio A/B Testing.
This component is the most important one. AWS Lambda is a serverless computing service that runs a piece of code in response to events. Also, it automatically manages everything, so you do not have to worry about server configuration, work loads, or anything else.
A lambda function is a unit fragment of your system that performs a concrete task. The most interesting part of this component is that you can connect each of these functions with any of the API calls that you created with API Gateway. Therefore, the function is executed whenever there is a specific request from the API, and its return value is the API’s response. It’s that simple. And it’s also cheap, because Amazon only charges you for the running time of your functions.
Right now Nelio Content has more than 70 lambda functions programmed in NodeJS, and we continue to expand the system with each improvement. Truth is, having your entire system this way makes it much easier to maintain, because if you find a bug in a function, you just have to fix it and re-upload that specific function.
Another important pillar of any system is data storage. In our case, and although there are other more traditional options available in Amazon, we chose to save the data in Amazon DynamoDB, a NoSQL solution with latencies of milliseconds.
If you are not used to NoSQL, you will need to change your mindset a little bit, as each table can store rows with different columns (except the primary keys, which must be present on each saved item). In addition, tables should be defined based on how you plan to query the data, since you can’t make joins between tables and you have to use indexes whenever you can to increase the efficiency of your queries.
After several months of accepting data and saving it in DynamoDB, we are still happy with the response times and everything provided by this component.
Perhaps this is Amazon’s most-known component to people who have ever heard of the Amazon cloud—a static file storage system. In WordPress it’s usually used to upload the image files from webs that have high storage needs. In our case, we used Amazon S3 to backup our Amazon DynamoDB data and to store a few extra assets.
Amazon SNS is a notification system. We use it as if it were a queue system. That is, when we have to process objects in great quantity, we enqueue them in SNS and they will be automatically processed one by one by the consumer of the queue. And, again, this consumer can also be a lambda function, which makes everything extremely consistent. ?
Finally, if you need to send emails to your customers, the best option is to use Amazon SES. This component allows us to send emails programmatically to the email accounts we want.
We use it to send emails to free trial users so that we can help them understand how Nelio Content works and make them feel more assisted during that period. We also use it to send emails to ourselves every time there is a new event in our payment system. This way, we get instant notifications (via email) every time a new customer subscribes to our service, makes a payment, or cancels their subscription.
Obviously, as we gained experience with the cloud of Amazon we have been using more and more components. First we started with the API Gateway, Lambda Functions, and DynamoDB only. But now we are using many other components (some of which do not appear in this article, to keep things simple). I encourage you to keep an eye on what the cloud of Amazon and other vendors (read Google, Microsoft, or even IBM) offer.
If you have some experience in cloud systems, I would love to read your thoughts on this topic. What do you think of our architecture? Does it seem right to you or do you think it could be made better?
Featured image by Anna Goncharova.