You probably heard someone talk about serverless technology around the office or at some conference conference your boss made you go and while understanding it’s merit as a technology doens’t come easy for a person without a technical background. With that said, I’d like to go over the biggest benefits of moving away from a traditional server and stepping into the cloud.
At its core, serverless is not the lack of servers but the existence of a server that does not need to be managed. Using microservices uploaded to Lambda that executes a little bit of code at a time and returning a value, you can build large-scale enterprise level application without having to see a single line of PHP. Now, this might not make everyone as happy as it does me but for a front-end developer like myself, that’s a godsend.
So Why Is This Such A Big Deal?
It stands to reason that any new technology trying to challenge the old ways of creating, running and hosting web and mobile apps will have a tough time getting support, yet the serverless community has grown exponentially in the past year and the reasons behind the movement are clear.
How Does This Affect Me And My Store?
Well, there are a number of major upgrades that a serverless approach can bring to your store. Let’s start with the obvious. The cut in costs. Using a serverless technology is cheaper than your traditional hosting and if you ever hosted a Magento store (or basically any other self-hosted solution) you’ll know just how expensive running, even a semi-successful store can be.
For AWS Lambda, the monthly compute price is $0.00001667 per GB-s and the free tier provides 400,000 GB-s. The monthly request price is $0.20 per 1 million requests and the free tier provides 1M requests per month.
There are more and more companies sharing their stories on how the cut costs using serverless and if you want to you can read about how companies save money with serverless.
The second reason why going serverless can be of significant value is the unparalleled scaling that can be achieved with serverless. If you do any online shopping around the holidays, especially during the “Black Friday” sales you probably saw your fair share of stores that were down, crumbling under the weight of countless users trying to browse, add to cart or compare products.
Creating microservices for all your websites functionality will improve your page load speed, remove scalability concerns and making changes to your code or business logic will be far easier to implement.
How Would This Even Work?
So how exactly would you go about switching your store from a traditional server and going serverless? To make things easier for everyone to understand I’ll won’t get too technical as doing so will turn this article into a 15K words software documentation, and let’s face it. I’m not smart enough to pull that sort of thing off. What I will do is break the store into small sections and explain how I would tackle the situation.
1. The CMS
I’m referring to the static pages like homepage, contact page, about us, etc. For this section use a caching system to create static pages from the CMS and have them served from a cloud service provider like AWS or Microsoft Azure. Most e-commerce content management systems (CMS) already come with a half decent caching solution so you might already be familiar with the concept.
Personally, I’d go with Amazon EslastiCache. It’s easy to install and deploy and won’t break the bank.
Amazon ElastiCache offers fully managed Redis and Memcached. Seamlessly deploy, operate, and scale popular open source compatible in-memory data stores. Build data-intensive apps or improve the performance of your existing apps by retrieving data from high throughput and low latency in-memory data stores. — Amazon ElasiCache
To keep this article short and sweat I’ll link[http://blog.e-zest.com/how-to-implement-aws-elasticache-in-magento/] to a tutorial on how you can integrate ElastiCache with Magento(as this is one of those platforms that just won’t work without proper caching).
2. The Catalog
The catalog is the part with all the categories and products and the main issue you have with them is the rendering speed. Having thousands of products with filters applied will slow your website to a halt. Now imagine having 10, 100 or 1000 concurrent users browsing, filtering and comparing products.
The Solution? Microservices!
Here is where AWS Lambda shines brightest. Every interaction that the user can have with the website is split into small functions. So having 10 people on your site or 1000 won’t make a dent in the page load time as AWS will scale to best fit your needs.
But Wait, There’s More!
The best part of this approach is the fact that you only pay what you use. That’s right. No more paying for big server bills when your store gets no visitors. Here’s a neat little AWS pricing to help you figure out what to expect in terms of cost.
Static files, like images and videos, can be served from S3 or even better: CloudFront to reduce costs and increase speed.
3. The Cart
This is probably the subject that most people that stayed this far along in the article are interested in. Carts are extremely complicated and cumbersome systems that will eat that CPU as if it were made out of tacos. The problem with conventional stores is MySQL bottlenecks and when that happens you entire website stops responding until MySQL catches up(either that or the entire thing just goes down).
The fix is not that complicated. Stop using MySQL! Since you are already using AWS Lambda why not use DynamoDB, it’s easy to setup, cheap and reliable and before you start calling me a sellout for pushing AWS on you all, MongoDB is another solid option, in fact, I kind of prefer it to DynamoDB as I’m more used to using it. Here’s a quick guide on how to get started with Lambda and MongoDB. Besides moving away from using MySQL, I’d urge anyone that gets a lot of orders to consider using an API like Magento’s API to handle orders. At the moment, having an expensive server with all the bells and whistle can withstand 3 to 5 orders/second which as it turns out, it’s still less than stores like Angry Birds store or Anki.com need.
So What’s The Problem?
Why isn’t anyone and everyone using this solution yet? There are a lot of people that already use this solution and it saves both time and a lot of money. So why are there still people not using this? One reason might be the fact that serverless is still a new technology. Not everyone feels comfortable with it yet and because it’s so new the tools needed for development are not popular enough. Take for example AWS Lambda debugging. It’s a basic need for every developer and yet Amazon doesn’t have a tool that provides all the support needed for development. So we end up looking for tools Like Thundra.io and Dashbird.io(amongst others).
Moving from a traditional self-hosted solution to the cloud will be a complex problem for store owners but at one point or another, they will find themselves having to face difficult decisions vis-a-vis their platform and scaling capabilities and going serverless can solve many problems.
I’m anxious to see what’s to come in the e-commerce space. Perhaps we’ll see our first in-the-cloud e-commerce solution. The sky’s the limit! (get it? cloud computing – sky? ok, I’ll stop)